您需要提供您的连接字符串“connectionString”
Public Shared Function Query(ByVal SQLString As String) As DataSet
Using connection As New SqlConnection(connectionString)
Dim ds As New DataSet()
Try
connection.Open()
Dim command As New SqlDataAdapter(SQLString, connection)
command.Fill(ds, "ds")
Catch ex As System.Data.SqlClient.SqlException
Throw New Exception(ex.Message)
End Try
Return ds
End Using
End Function
这是一个返回DataSet的函数。
调用非常简单。
如果您有什么不清楚的可以继续追问!希望能帮到您!
这里以OERACLE数据库为例 :Provider=MSDAORAdata source =主机名:1521/ORCLUser ID=systemPassword=ORACLEUnicode=True
Dim myConn As Data.OleDb.OleDbConnection
myConn = New System.Data.OleDb.OleDbConnection()
myConn.ConnectionString = strCon
myConn.Open()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)