VB SQL Connectivity through Internet.
-
I have developed a client-server application in VB6 and SQL Server 7 as backend. The application works fine in our intranet. But I want to connect to the SQL Server physically located in our second office which is in different city. We have a fixed IP address. I am facing a problem in connecting to the SQL server. I have tried with DSN, provider, .udl file. How do I accomplish ths?
-
I have developed a client-server application in VB6 and SQL Server 7 as backend. The application works fine in our intranet. But I want to connect to the SQL Server physically located in our second office which is in different city. We have a fixed IP address. I am facing a problem in connecting to the SQL server. I have tried with DSN, provider, .udl file. How do I accomplish ths?
I have done this many times with the following code. Basically, I create a connection string and use ADO and OLEDB to perform the connection. Here is a code snippet. strServerName = "127.0.0.1" ' Substitute your IP Address here strDatabaseName = "YourDB" ' Substitute your Database name strUserName = "YourUser" ' Substitute your UserName strPassword = "Password" ' and Pasword here. ' Initialize the database connection string mstrConnStr = "server=" & strServerName & ";database=" & strDatabaseName & ";provider=SQLOLEDB;uid=" & strUserName & ";pwd=" & strPassword ' Instantiate an ADO Connection Object - Trivial code left out ' Then, open the connection. mobjConn.Open mstrConnStr ' Do some error checking here That's all there is to it! Rob
-
I have developed a client-server application in VB6 and SQL Server 7 as backend. The application works fine in our intranet. But I want to connect to the SQL Server physically located in our second office which is in different city. We have a fixed IP address. I am facing a problem in connecting to the SQL server. I have tried with DSN, provider, .udl file. How do I accomplish ths?
You need to make sure that the SQL Server is set up to use TCP\IP protocol and then on your client machines in the setup of the DSN you need to make sure they are trying to connect via TCP and not Named Pipes (which would only work in you intranet). Jason Cono, MCSD