level 1
Dim objConn As New OleDb.OleDbConnection
Dim objDa As New OleDb.OleDbDataAdapter
Dim objComm As New OleDb.OleDbCommand
Dim objDs As New DataSet
Dim a As String
a = ""
If TextBox1.Text <> "" Then
a = "ChengYu like '%" + TextBox1.Text + "%'"
End If
objConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source = ChengYu.accdb"
objComm.CommandText = "Select ChengYu as 成语,PingYin as 拼音,DianGu as 解释 From ChengYuDaQuan"
If a <> "" Then
objComm.CommandText = objComm.CommandText & " where " & a
End If
objComm.Connection = objConn
objDa.SelectCommand = objComm
objConn.Open()
objDa.Fill(objDs, "ChengYuDaQuan")
objConn.Close()
DataGridView1.DataSource = objDs.Tables("ChengYuDaQuan")
2016年11月03日 01点11分