'定义一个数据集对象
Public objDataSet As DataSet
'定义一个数据视图对象
Public objDataView As DataView
'定义一个数据适配器对象
Public objDataAdpter As SqlDataAdapter
'定义一个数据连接对象,并初始化
Public objSqlConnection As SqlConnection = New SqlConnection("data source=COOLSER;initial catalog=technic;user id=sa;password=")
'定义一个当前的绑定管理对象
Public objCurrencyMannager As CurrencyManager
'定义了查询语句
Public UserSqlstr As String = "SELECT * FROM Docu_system"
Public Function SelectData(ByVal sqlstr As String) As DataSet
objDataSet = New DataSet
objDataSet.Clear()
'实例化一个数据集对象
Try
objSqlConnection.Open()
'打开数据库连接
objDataAdpter = New SqlDataAdapter(sqlstr, objSqlConnection)
'将数据库的数据映射到数据适配器
objDataAdpter.Fill(objDataSet)
'填充数据集的数据
objSqlConnection.Close()
'关闭数据连接,这一点很重要
Catch
MsgBox("错误号:" & Err.Number & "错误描述:" & Err.Description)
End Try
Return objDataSet
objDataSet = Nothing
End Function
Public Function UpdateData(ByVal sqlstr As String) As Boolean
Dim objCommand As SqlCommand = New SqlCommand
Try
objSqlConnection.Open()
objCommand.Connection = objSqlConnection
objCommand.CommandText = sqlstr
objCommand.CommandType = CommandType.Text
objCommand.ExecuteNonQuery()
objSqlConnection.Close()
Catch
MsgBox("错误号:" & Err.Number & "错误描述:" & Err.Description)
Return False
End Try
Return True
End Function
问题点数:100、回复次数:7
◆◆
评论读取中....
请登录后再发表评论!
◆◆
修改失败,请稍后尝试