السلام عليكم ورحمة الله
ما هو الخطأ في هذا الكود عند إضافه معلومات ال instructor في جدول وإضافه instructorID والcourseID إلى جدول آخر باستخدام إتصالين مختلفين ...
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String = "Data Source=data source name;Initial Catalog=databaseName;Integrated Security=True"
Dim conn As New SqlConnection(str)
Dim conn2 As New SqlConnection(str)
If conn.State = Data.ConnectionState.Closed Then
conn.Open()
End If
If conn2.State = Data.ConnectionState.Closed Then
conn2.Open()
End If
Dim ocmd As New SqlCommand
Dim oc As New SqlCommand
ocmd.Connection = conn
oc.Connection = conn2
Dim s As String = "insert into INSRTUCTOR(InstructorID, Password, Fname, Mname, Lname, sex, Email, HPhone, MPhone, SpecialtyID) values('" & IDTextBox.Text & "','" & PasswordTextBox.Text & "','" & fnameTextBox.Text & "','" & MiddelNameTextBox.Text & "','" & LastNameTextBox.Text & "','" & SexDropDownList.SelectedItem.Text & "','" & EmailTextBox.Text & "','" & PhoneTextBox.Text & "','" & MobilePhoneTextBox.Text & "','" & SPDropDownList.SelectedItem.Text & "')"
Dim s2 As String = "insert into TEACH(CourseID, InstructorID) values('" & CoursesCheckBoxList.SelectedItem.Text & "','" & IDTextBox.Text& "'"
ocmd.CommandText = s
oc.CommandText = s2
If ocmd.ExecuteNonQuery() Then
LabelResult.Text = "successful inserted in Instructor table"
End If
If oc.ExecuteNonQuery() Then
Label5.Text = "Successful inserted in TEACH Table"
End If
End Sub
يظهر الخطأ في السطر التالي
If oc.ExecuteNonQuery() Then
هدي رساله الخطأ
Incorrect syntax near '90909'.
و 90909 هو ال instructorID المدخل
أتمنى منكم الرد ....