一小段C#代码,帮转成VB的,谢谢(在线等)
namespaceWenJuanXT{///<summary>///DB的摘要说明。///</summary>publicclassDB{publicDB(){//TOD...
namespace WenJuanXT
{
/// <summary>
/// DB 的摘要说明。
/// </summary>
public class DB
{
public DB()
{
// TODO: 在此处添加构造函数逻辑
//
}
public static SqlConnection createConnection()
{
SqlConnection con=new SqlConnection("server=(LOCAL);database=wenjuan;uid=sa;pwd=123;");
return con;
}
}
} 展开
{
/// <summary>
/// DB 的摘要说明。
/// </summary>
public class DB
{
public DB()
{
// TODO: 在此处添加构造函数逻辑
//
}
public static SqlConnection createConnection()
{
SqlConnection con=new SqlConnection("server=(LOCAL);database=wenjuan;uid=sa;pwd=123;");
return con;
}
}
} 展开
3个回答
展开全部
Namespace WenJuanXT
''' <summary>
''' DB 的摘要说明。
''' </summary>
Public Class DB
Public Sub New()
' TODO: 在此处添加构造函数逻辑
'
End Sub
Public Shared Function createConnection() As SqlConnection
Dim con As New SqlConnection("server=(LOCAL);database=wenjuan;uid=sa;pwd=123;")
Return con
End Function
End Class
End Namespace
''' <summary>
''' DB 的摘要说明。
''' </summary>
Public Class DB
Public Sub New()
' TODO: 在此处添加构造函数逻辑
'
End Sub
Public Shared Function createConnection() As SqlConnection
Dim con As New SqlConnection("server=(LOCAL);database=wenjuan;uid=sa;pwd=123;")
Return con
End Function
End Class
End Namespace
展开全部
Function GetAdoConn() As ADODB.Connection
Dim pConn As ADODB.Connection
Set pConn = CreateObject("adodb.connection")
Dim tempStr As String
Dim tempServer As String
Dim tempDb As String
Dim tempUser As String
Dim tempPass As String
tempServer = "(LOCAL)"
tempDb = "wenjuan"
tempUser = "sa"
tempPass = "123"
tempStr = "Provider=SQLOLEDB.1;Password=" & tempPass & _
";Persist Security Info=True;User ID=" & tempUser & _
";Initial Catalog=" & tempDb & ";Data Source=" & tempServer
pConn.ConnectionString = tempStr
pConn.CursorLocation = 3
pConn.ConnectionTimeout = 60
pConn.CommandTimeout = 60
pConn.Open
Set GetAdoConn = pConn
End Function
Dim pConn As ADODB.Connection
Set pConn = CreateObject("adodb.connection")
Dim tempStr As String
Dim tempServer As String
Dim tempDb As String
Dim tempUser As String
Dim tempPass As String
tempServer = "(LOCAL)"
tempDb = "wenjuan"
tempUser = "sa"
tempPass = "123"
tempStr = "Provider=SQLOLEDB.1;Password=" & tempPass & _
";Persist Security Info=True;User ID=" & tempUser & _
";Initial Catalog=" & tempDb & ";Data Source=" & tempServer
pConn.ConnectionString = tempStr
pConn.CursorLocation = 3
pConn.ConnectionTimeout = 60
pConn.CommandTimeout = 60
pConn.Open
Set GetAdoConn = pConn
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这段代码主要用于建立数据库联接,改成VB代码如下:
' 首先在VB中引用“Microsoft ActiveX Data Objects 2.8 Library”
Dim cn As New ADODB.Connection
cn.Open "Provider=SQLOLEDB.1;Password=123;Persist Security Info=False;User ID=sa;Initial Catalog=wenjuan;Data Source=(LOCAL)
' 首先在VB中引用“Microsoft ActiveX Data Objects 2.8 Library”
Dim cn As New ADODB.Connection
cn.Open "Provider=SQLOLEDB.1;Password=123;Persist Security Info=False;User ID=sa;Initial Catalog=wenjuan;Data Source=(LOCAL)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询