September 28, 2009 at 5:37 am
Hi
I have a VB6 program working with a SQL Server database on a LAN
Can I connect to the database if loaded on a web server
Can I do this with VB6 and If yes is there a mojor code change needed ?
September 29, 2009 at 12:57 am
I had the same problem sometime ago. Eventually we created a VPN so things were easy after that.
Anyway there is no reason that you shouldn't be able to to it, as long as your sql server and you firewall is configured to receive incoming remote connections. There is a security concern here, and maybe changing the default listening port from 1433 to something else would be a good idea.
ADO on the other hands simply needs a valid connection string. check out:
http://www.connectionstrings.com/
Once your connection has been set up then there is no needed code change in your VB source.
There is a catch of course:if your application has been designed to work over LAN speeds then you might have to make adjustments on the way you fetch recordsets, or the amount of roundtrips you make, or even change some parts to asynchronous execution.
September 29, 2009 at 1:06 am
Thanks a ton.. will give it a try and keep posted for issues
November 29, 2009 at 4:37 am
Thanks so much for that URL. I'm still trying to get to grips with connection strings, and there are all the examples one could ever want!
[Sorry about the DUP, thought it hadn't posted, after 10 mins of 'WAIT' and a refresh. Posted again, but now found it had. Is there a DELETE?]
November 29, 2009 at 4:58 am
Thanks so much for that URL. I'm still trying to get to grips with connection strings, and there are all the examples one could ever want! 😎
November 29, 2009 at 6:28 am
David Data
I'm still trying to get to grips with connection strings, and there are all the examples one could ever want!
I have used this code for years, figuring it is easier for the code to determine the connection string compared to my attempting to figure it out.
'
'In project references you MUST select
' Microsoft OLE DB Service Component 1.0 Type Library
' This in turn loads oledb32.dll into your project
' then
'
'
' In project reference you MUST select
' Microsof ActiveX Data Objects 2.8 Library
' This in turn loads Msado15.dll into your project
'
' Note if invoking the approle then pay attention to:
'
' http://www.sqlservercentral.com/Forums/Topic533262-146-5.aspx#bm568983
'
'
Dim objMSDAC As MSDASC.DataLinks
Dim I As Integer
Dim J As Integer
Dim Errx As Long
On Error GoTo E_Han
Set objMSDAC = New MSDASC.DataLinks
'
'Display the form contained withing the DLL and allow the user
'to select the database, authentication mode and password if required
'then user clicks on CONNECT button to test input then O.K. to return to
'
Cnn_String = objMSDAC.PromptNew
'
' Returns to the program here
'
Cnn.ConnectionString = Cnn_String
'
' Extract database name
'
I = InStr(1, Cnn_String, "Initial Catalog")
Dbnamr = Mid(Cnn_String, I + 16, Len(Cnn_String) - (I + 15))
'
' Extract Catalog Name
'
J = InStr(1, Dbnamr, ";")
Catalog_Name = Left(Dbnamr, J - 1)
November 30, 2009 at 5:55 am
"I have a VB6 program working with a SQL Server database on a LAN
Can I connect to the database if loaded on a web server"
If you with web server mean a SQL Server hosted on inter or an intranet
with an IP adr you can use remote OLDB.
search Google sqloledb connection string
If you can ping the serverthen it should work. Talk to your net administrator.
An example I use VB6 or VBA (inside Excel).
Sub test()
dim conn As New ADODB.Connection
conn.Provider = "sqloledb"
conn.Properties("Network Library").Value = "DBMSSOCN"
conn.Properties("Data source").Value = "IPadr,1433" ‘Or computer name, 1433 is the default port
conn.Properties("User id").Value =”someone”
conn.Properties("Password").Value = "XXXX"
conn.Properties(“Initial Catalog”.Value = “Databasename”
conn.Open source
etc
end sub
/Gosta
November 13, 2010 at 5:34 am
It is very easy to connect any type of vb6 / vb.net app with web server. only connection string should be updated. any questions may be forwarded at support@thesuntech.com.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply