我想從兩個表在MySQL閱讀:從vb.net數據讀取多個表中讀取
Dim sqlcom As MySqlCommand = New MySqlCommand("Select * from mother, father where IDNO= '" & TextBox14.Text & "' ", sqlcon)
- 但是我得到這個錯誤:
Column 'IDNO' in where clause is ambiguous
這裏是整個代碼:
Dim NoAcc As String
Dim NoAccmod2 As String
Dim NoPas As String
Dim sqlcon As New MySqlConnection("Server=localhost; Database=school;Uid=root;Pwd=nitoryolai123$%^;")
Dim sqlcom As MySqlCommand = New MySqlCommand("Select * from mother, father where IDNO= '" & TextBox14.Text & "' ", sqlcon)
sqlcon.Open()
Dim rdr As MySqlDataReader
rdr = sqlcom.ExecuteReader
If rdr.HasRows Then
rdr.Read()
NoAcc = rdr("IDNO")
If (TextBox14.Text = NoAcc) Then TextBox7.Text = rdr("MOTHER")
If (TextBox14.Text = NoAcc) Then TextBox8.Text = rdr("MOTHER_OCCUPATION")
If (TextBox14.Text = NoAcc) Then TextBox10.Text = rdr("FATHER")
If (TextBox14.Text = NoAcc) Then TextBox11.Text = rdr("FATHER_OCCUPATION")
End If
- 有什麼建議可以幫助解決這個問題嗎? 甚至還有其他技術可以實現使用數據讀取器從兩個表中讀取數據的目標?
這是一個WinForm,而不是一個Web表單
僅供參考,您的代碼是受到SQL注入攻擊。 http://stackoverflow.com/questions/tagged/sql-injection – Josh 2010-03-18 04:54:50