am using vb.net and sql database.
My tables are as follows:
Details:
Details_ID (PK)
Address_1
Address_2
City
Postcode
Country
Email
And Customers:
Cust_ID
Customer_Name
Notes
Details_ID(FK)
When i insert data, it fills in the tables but the Details_ID comes as Null. I need the Details ID to correspond with the Customer. All this to happen in one form.
My code is as show below:
Private Sub btn_submit_Click(sender As System.Object, e As System.EventArgs) Handles btn_submit.Click
Dim COn As String = "Insert into [Details] ( Address_1, Address_2, City, Postcode, Country, Email) VALUES ('" & txt_add1.Text & "','" & txt_add2.Text & "','" & txt_city.Text & "','" & txt_postcode.Text & "','" & txt_country.Text & "','" & txt_email.Text & "')"
COn &= "Insert into [Customers] (Customer_Name, Notes) VALUES ('" & txt_cust_name.Text & "', ' " & txt_notes.Text & "')"
Dim dr As Data.SqlClient.SqlDataReader = GetDataReader(gCOn)
'cmd.ExecuteNonQuery()
'txt_security_level_ID.Clear()
'txt_position.Clear()
Try
Catch ex As Exception
MessageBox.Show("Error while inserting record." & ex.Message, "Insert Records")
End Try
Me.Close()
Add_Customer.ShowDialog()
End Sub
any help would be appreciated :)