将VB6转换为VB2010代码

时间:2015-06-11 05:52:32

标签: vb.net vb6

美好的一天,请帮我将下面的代码(VB6)转换为VB 2010,

Dim strconn As String
Dim condtl() As String

Open "c:\databaseSetting\dbsettings.dat" For Input As #1
Line Input #1, strconn
Close #1

strconn = Replace(strconn, """", "")
condtl = Split(strconn, ",")

Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;data source=" & condtl(0) & ";initial catalog=" & condtl(1) & ";user id=" & condtl(2) & ";password=" & condtl(3)
cn.Open

1 个答案:

答案 0 :(得分:2)

不是为你转换代码,我会给你一些指示:

打开文件并阅读以下行:

https://msdn.microsoft.com/en-us/library/db5x7c0d%28v=vs.110%29.aspx https://msdn.microsoft.com/en-us/library/ms143368%28v=vs.110%29.aspx(如果文件很小,则更简单)

对于字符串替换,您可以使用字符串函数'Replace':

https://msdn.microsoft.com/en-us/library/system.string.replace%28v=vs.110%29.aspx

对于类似的数据库操作(即打开ADODB.Connection),您可以在这里学习:

https://support.microsoft.com/en-us/kb/308047