Working on a project and wanted to make sure I am on the right track. This is my SQL Insert snippet. Is this the right way to do an Insert? It works just want to be sure I'm not missing anything.
TIA
This is my connection string. I have it in a module so I can use it other places.
Public conn_string As String = "server=SQL_2005;database=Test;UID=sa;Pwd=test"
Dim cn As New SqlConnection(conn_string)
Dim objCommand As New SqlCommand("", cn)
cn.Open()
objCommand.CommandText = "INSERT INTO patient_images(ENTERPRISE_ID,PRACTICE_ID,PERSON_ID,ENC_ID,ORIG_IMAGE_FILE,IMAGE_DESC,IMAGE_FILE,IMAGE_ID,CREATED_BY, MODIFIED_BY) VALUES('" & enterprise_id & "','" & practice_id & "', '" & person_id & "', '" & enc_id & "', '" & orig_image_file & "', '" & image_desc & "', '" & image_file & "', '" & image_id & "', '" & created_by & "', '" & modified_by & "')"
objCommand.ExecuteNonQuery()
cn.Close()
cn = Nothing
TIA
This is my connection string. I have it in a module so I can use it other places.
Public conn_string As String = "server=SQL_2005;database=Test;UID=sa;Pwd=test"
Dim cn As New SqlConnection(conn_string)
Dim objCommand As New SqlCommand("", cn)
cn.Open()
objCommand.CommandText = "INSERT INTO patient_images(ENTERPRISE_ID,PRACTICE_ID,PERSON_ID,ENC_ID,ORIG_IMAGE_FILE,IMAGE_DESC,IMAGE_FILE,IMAGE_ID,CREATED_BY, MODIFIED_BY) VALUES('" & enterprise_id & "','" & practice_id & "', '" & person_id & "', '" & enc_id & "', '" & orig_image_file & "', '" & image_desc & "', '" & image_file & "', '" & image_id & "', '" & created_by & "', '" & modified_by & "')"
objCommand.ExecuteNonQuery()
cn.Close()
cn = Nothing