inserting fields in a related database
hi ...
i have created a relational database and my two tables
1)internet and
2)internet_payment
have code_org,duration_hrs as composite keys....
now i have created a form to insert values to it bt it is nt
working...
my code is listed below....
Dim con As OleDbConnection
Dim str2 As String
Dim str3 As String
Dim com2 As OleDbCommand
Dim com3 As OleDbCommand
con = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA Source=C:\Documents and Settings\nitpu.ITPVIS19\My Documents\ProjectPtu.mdb")
str2 = "insert into internet_payment(code_org,duration_hrs,amount,bank ,dd_no,dd_date) values(@code_org,@duration_hrs,@amount,@bank,@dd_n o,@dd_date)"
str3 = "insert into internet(code_org,duration_hrs) values(@code_org,@duration_hrs)"
com2 = New OleDbCommand(str2, con)
com3 = New OleDbCommand(str3, con)
com2.Parameters.Add("@code_org", TextBox1.Text)
com2.Parameters.Add("@duration_hrs", DropDownList2.SelectedItem.Text)
com2.Parameters.Add("@amount", DropDownList3.SelectedItem.Text)
com2.Parameters.Add("@bank", TextBox12.Text)
com2.Parameters.Add("@dd_no", TextBox13.Text)
com2.Parameters.Add("@dd_date", TextBox14.Text)
com3.Parameters.Add("@code_org", TextBox1.Text)
com3.Parameters.Add("@duration_hrs", DropDownList2.SelectedItem.Text)
con.Open()
com2.ExecuteNonQuery()
com3.ExecuteNonQuery()
con.Close()
bt the program gives the following error...
"You cannot add or change a record because a related record is required in table 'internet'"
as im new to asp.net so i need some help to it
any help would be gr8
thnx in advance
|