VB6.0
代码转VB.NET 大家好,能否帮我把下面
代码转成VB.NET的?谢谢! 其实中UnzipPhoto是我引用的外部DLL
文件 dim str
sql as string Dim test As UnzipPhoto.clsUnzipPhoto Dim cnDataBase As ADODB.Connection Dim rsExpPortPhoto As ADODB.Recordset Set rsExpPortPhoto = New ADODB.Recordset Set test = New UnzipPhoto.clsUnzipPhoto str
sql = "SELECT top 1 number,Photo FROM Employees WHERE Photo IS NOT NULL " rsExpPortPhoto.Open str
sql,cnDataBase,adOpenForwardOnly,adLockReadOnly aa.PhotoUnZip rsExpPortPhoto,"C:/photo" __________________________________________________________________________ __________________________________________________________________________ VB.NET codetest __________________________________________________________________________ 现在对
数据库的操作基本上是使用ADO.NET 我在这里给你使用ADO.NET的
代码,希望对你有帮助: Imports System.Data.
sqlClient Imports System.Data Public Class clsExecute
sql Shared Function Execute
sql(ByVal
sql As String) As DataTable Try Dim CONN As String ''对
数据库连接的配制 CONN = "data source=localhost;Database=HAWK;Integrated Security=SSPI;" Dim
sqlConn As New
sqlConnection(CONN) Dim cmd As
sqlCommand = New
sqlCommand(
sql,
sqlConn) cmd.CommandType = CommandType.Text Dim sTokens() As String sTokens =
sql.Split(" ") ''执行
数据库的插入、
删除、更新等操作 If Strings.InStr("INSERT,DELETE,UPDATE",sTokens(0).ToUpper) Then If
sqlConn.State <> ConnectionState.Open Then
sqlConn.Open() ''打开
数据库连接 End If cmd.ExecuteNonQuery() ''执行
sql语句 If
sqlConn.State <> ConnectionState.Closed Then
sqlConn.Close() ''
关闭数据库连接 End If Return Nothing ''执行
数据库的
查询操作 Else Dim ObjectdsDataSet As New DataSet() Dim adapter As New
sqlDataAdapter() adapter.SelectCommand = cmd If
sqlConn.State <> ConnectionState.Open Then
sqlConn.Open() ''打开
数据库连接 End If cmd.ExecuteNonQuery() ''执行
sql语句 If
sqlConn.State <> ConnectionState.Closed Then
sqlConn.Close() ''
关闭数据库连接 End If adapter.Fill(ObjectdsDataSet) ''填充数据集 Return ObjectdsDataSet.Tables(0) End If Catch Msg
Box(Err.Description) End Try Return Nothing End Function End Class __________________________________________________________________________
原文链接:https://www.f2er.com/vb/264075.html