嘿伙计们,我遇到了一个问题对象引用未设置为对象的实例。我是一个完整的初学者,所以任何说明/解决方案将不胜感激。
导入 System.Data.SqlClient 导入 MySql.Data.MySqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim connectionstring As String
Dim commandtext As String
Dim da As MySqlDataAdapter
Dim table As DataTable
commandtext = "select * From student"
connectionstring = "Server=*****;Database=Harry;Uid=****;Pwd=****;Allow Zero Datetime=True;"
Try
da = New MySqlDataAdapter(commandtext, connectionstring)
table = New DataTable
da.Fill(table)
DataGridView1.DataSource = table
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Dim ds As New DataSet
da = New MySqlDataAdapter
da.Fill(ds, "student")
DataGridView1.DataSource = ds.Tables("student")
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
ds.Tables("student").DefaultView.RowFilter = "student_id LIKE '%" & TextBox1.Text & "%' OR name LIKE '%" & TextBox1.Text & "*'"
End Sub
结束类