cmbo ボックスを使用して、SQL データベース内のデータ レコードを検索しようとしています。この「'=' 付近の構文が正しくありません」の後に、「マルチパート識別子 "System.Data.DataRowView" が見つかりませんでした」というエラーが表示されます。私のコードを以下に示します。
Private Sub BTNEDIT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNEDIT.Click
refreshComboBox()
CMBID.SelectedText = "Select"
End Sub
Private Sub refreshComboBox()
getConnect()
Try
Conn.Open()
Dim strSQL As String = "SELECT * FROM EMPLOYEE ORDER BY EMP_ID ASC"
Dim da As New SqlDataAdapter(strSQL, Conn)
Dim ds As New DataSet
da.Fill(ds, "EMPLOYEE")
CMBID.DataSource = ds.Tables(0)
CMBID.DisplayMember = "EMP_ID"
CMBID.ValueMember = "ID"
CMBID.SelectedValue = 0
CMBID.Invalidate()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
Conn.Close()
End Try
End Sub
Private Sub CMBID_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CMBID.SelectedIndexChanged
Dim gend As String
getConnect()
Dim strSQL As String = "SELECT * FROM EMPLOYEE WHERE EMP_ID=" & CMBID.Text & ""
Try
Dim da As SqlDataAdapter = New SqlDataAdapter(strSQL, Conn)
Dim ds As DataSet = New DataSet
da.Fill(ds, "EMPLOYEE")
Dim dt As DataTable = ds.Tables("EMPLOYEE")
Dim row As DataRow
For Each row In dt.Rows
ID.Text = row("ID")
TXTNAME.Text = row("EMP_NAME")
TXTFNAME.Text = row("EMP_FNAME")
gend = row("EMP_GENDER")
If gend = "MALE" Then
RBMALE.Checked = True
RBFEMALE.Checked = False
ElseIf gend = "FEMALE" Then
RBFEMALE.Checked = True
RBMALE.Checked = False
End If
DTPEMPDOB.Value = row("EMP_DOB")
TXTCASTE.Text = row("EMP_CAST")
CMBDEPT.Text = row("EMP_DEPART")
CMBDESIG.Text = row("EMP_DESIG")
DTPEMPDOJ.Value = row("EMP_DOJ")
MTXTSAL.Text = row("EMP_SALARY")
MTXTPFESI.Text = row("EMP_PF_ESI")
TXTBRANCH.Text = row("EMP_BRANCH")
MTXTCONTACT.Text = row("EMP_CONTACT")
RTXTADDRESS.Text = row("EMP_ADDRESS")
Next row
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
Conn.Close()
End Try
End Sub
私のコードをチェックして解決策を教えてください。