[VB.NET]VB6.0代码转VB.NET

前端之家收集整理的这篇文章主要介绍了[VB.NET]VB6.0代码转VB.NET前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
VB6.0代码转VB.NET 大家好,能否帮我把下面代码转成VB.NET的?谢谢! 其实中UnzipPhoto是我引用的外部DLL文件 dim strsql 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 strsql = "SELECT top 1 number,Photo FROM Employees WHERE Photo IS NOT NULL " rsExpPortPhoto.Open strsql,cnDataBase,adOpenForwardOnly,adLockReadOnly aa.PhotoUnZip rsExpPortPhoto,"C:/photo" __________________________________________________________________________ __________________________________________________________________________ VB.NET codetest __________________________________________________________________________ 现在对数据库的操作基本上是使用ADO.NET 我在这里给你使用ADO.NET的代码,希望对你有帮助: Imports System.Data.sqlClient Imports System.Data Public Class clsExecutesql Shared Function Executesql(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 MsgBox(Err.Description) End Try Return Nothing End Function End Class __________________________________________________________________________

猜你在找的VB相关文章