Dim mycon222 = New OleDbCommand(sqlstr1, mycon111)
其中mycon111已定义为New OleDbConnection,sqlstr1为string。请教大神解释一下这句话拆开来是什么意思
能不能代码写一下?我只知道有dim mycon222 as new oledbcommand
然后之后怎么写?
Dim mycon222 = New OleDbCommand(sqlstr1, mycon111)
其中mycon111已定义为New OleDbConnection,sqlstr1为string。请教大神解释一下这句话拆开来是什么意思
能不能代码写一下?我只知道有dim mycon222 as new oledbcommand
然后之后怎么写?
连接数据库吗?下面函数是我自己写的vb.net查询数据库函数:
sql传递SQL语句,dt返回查询结果;当查询出错时函数返回False,err保存错误信息
Public Function selectbd(ByVal sql As String, ByVal conn As String, ByRef dt As DataTable, ByVal err As String) As Boolean
Try
Dim objconn As New OledbConnection(conn)
Dim objcomm As New OledbCommand
Dim objda As New OledbDataAdapter
Dim objdt As New DataTable
objcomm.CommandText = sql
objcomm.CommandType = CommandType.Text
objcomm.Connection = objconn
objda.SelectCommand = objcomm
objconn.Open()
objda.Fill(objdt)
dt = objdt
Return True
objconn.Close()
Catch ex As Exception
err = ex.Message
Return False
End Try
End Function