请帮助他解决此代码和此错误
错误1重载解析失败,因为无法访问'新的'可 在没有缩小转换的情况下调用: ' Public Sub New(selectCommandText As String,selectConnection As System.Data.OleDb.OleDbConnection)&#39 ;: Argument matching parameter ' selectConnection'来自'对象'至 ' System.Data.OleDb.OleDbConnection&#39 ;. ' Public Sub New(selectCommandText As String,selectConnectionString As String)':参数匹配参数 ' selectConnectionString'来自'对象'至 '字符串&#39 ;. F:\ project \ B-tech \ FirstVBproject \ LMSapp \ LMSapp \ book \ updatecate.vb 89 23 LMSapp
Dim int As Integer
Dim cnnOLEDB As New OleDbConnection
Dim cmdOLEDB As New OleDbCommand
Dim rdr1 As OleDbDataReader
'Dim dataadp As New OleDbDataAdapter
Dim cmdInsert As New OleDbCommand
Dim cmdUpdate As New OleDbCommand
Dim cmdDelete As New OleDbCommand
Dim csearce As String
Dim cmdsearch As New OleDbCommand
Dim cnn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\project\B-tech\FirstVBproject\LMSapp\LMSapp\Library2.accdb")
Private Sub BunifuFlatButton3_Click(sender As Object, e As EventArgs) Handles BunifuFlatButton3.Click
cnn.Open()
Try
Dim search As String = srctxt.text
Dim dataT As New DataTable
Dim dataS As New DataSet
dataS.Tables.Add(dataT)
Dim dataadp As New OleDbDataAdapter
dataadp = New OleDbDataAdapter("select * from Category where ID like '%" & srctxt.text & "%'", cnn)
'dataadp = New OleDbDataAdapter("select * from Category where ID like '%" & srctxt.text & "%'", cnnOLEDB)
dataadp.Fill(dataT)
DataGridView1.DataSource = dataT.DefaultView
Catch ex As Exception
MsgBox(ex.ToString)
End Try
cnn.Close()
end sub()
答案 0 :(得分:0)
如果要将数据加载到datagrid视图中。您可以在下面编辑我的代码。
'DGVforUSERNAME HA LOAD
Dim ConnString As String = "provider= Microsoft.ACE.OLEDB.12.0; Data Source=D:\Users\rjimenez\Documents\QAdatabase.mdb"
Dim SQLString As String = "SELECT Username, User FROM QAForHA where User='" & txtUser.Text & "'"
Dim OleDBConn As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(ConnString11)
Dim DataSet As New DataSet()
Dim OleDbDataAdapter As System.Data.OleDb.OleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter(SQLString11, OleDBConn11)
OleDBConn.Open()
OleDbDataAdapter.Fill(DataSet, "QAForHA")
DgvUsernameHA1.DataSource = DataSet.Tables("QAForHA")