Convert VB6 to VB2010 code

90 views Asked by At

Good Day, Please help me to convert the code below (VB6) to 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

There are 1 answers

0
James Harcourt On

Rather than convert code for you, I'll give you some pointers:

To open a file and read the lines:

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 (simpler if the file is small)

For string substitution you can use the string function 'Replace':

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

And for a like-for-like database operation (i.e. opening an ADODB.Connection) you can learn here:

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