我的代码有什么问题?它一直显示这个错误,并且无法从数据库中提取任何条目
下面是代码:
Private Async Sub connDatabase()
searchDrop.Text = ""
searchValue.Text = ""
If tableTypeLabel.Text = "pis" Then
sqlQ = "SELECT CAASN, First_Name, Middle_Name, Last_Name, Occupation, Platoon, CAA_Company, Status FROM @tabNam;"
ElseIf tableTypeLabel.Text = "dlt" Then
MessageBox.Show("Info not available")
Me.Close()
End If
dataTab.Rows.Clear()
dataTab.Columns.Clear()
Try
Await sqlConn.OpenAsync()
sqlComm.CommandType = CommandType.Text
sqlComm.CommandText = sqlQ
sqlComm.Parameters.AddWithValue("@tabNam", companyTagLab.Text)
sqlAdap = New MySqlDataAdapter(sqlComm.CommandText, sqlConn)
val = sqlAdap.Fill(dataTab)
Await sqlConn.CloseAsync()
If val > 0 Then
listFilt.DataSource = dataTab
listView.DataSource = Nothing
listView.Rows.Clear()
listView.Columns.Clear()
listView.DataSource = listFilt
ElseIf val < 1 Then
MessageBox.Show("Data not available!")
End If
dataTab = Nothing
Catch ex As Exception
MessageBox.Show(ex.Message)
Console.WriteLine(ex.Message)
End Try
End Sub
1条答案
按热度按时间im9ewurl1#
此问题与以下字符串有关:
删除该参数,并将其更改为:
确保
companyTagLab.Text
不会使您容易受到SQL注入攻击!