基于mysql的数据网格
我正试图使用这段代码在网格上显示,其中信息是根据前面标记的字段进行研究的基于mysql的数据网格,mysql,sql,vb.net,Mysql,Sql,Vb.net,我正试图使用这段代码在网格上显示,其中信息是根据前面标记的字段进行研究的 SQL = "SELECT * FROM funcionario WHERE setor ='" + TxtPesq.Text + "'" myCommand.Connection = conn myCommand.CommandText = SQL myAdapter.SelectCommand = myCommand
SQL = "SELECT * FROM funcionario WHERE setor ='" + TxtPesq.Text + "'"
myCommand.Connection = conn
myCommand.CommandText = SQL
myAdapter.SelectCommand = myCommand
myAdapter.Fill(myData)
DataGridView1.DataSource = myData
- 使用
使用
语句正确处理对象
- 参数化查询以避免sql注入
Dim dSet As New Dataset
Dim SQL AS String= "SELECT * FROM funcionario WHERE setor = @setor"
Using conn As New MySqlConnection("connectionStr HERE")
Using myCommand As New MysqlCommand()
With MyCommand
.Connection = conn
.CommandText = SQL
.CommandType = CommandType.Text
.Parameters.AddWithValue("@setor", TxtPesq.Text)
End With
Using myAdapter As New MySQLDataAdapter(myCommand)
Try
myAdapter.Fill(dset)
DataGridView1.DataSource = dset.tables(0)
Catch(ex as MySQLException)
Msgbox (ex.Messge)
End Try
End Using
ENd Using
ENd Using
到底是什么不起作用?请提供更多详细信息。您好,您能检查mydata对象中正在提交的数据吗。。。?