August 28, 2005 at 4:14 am
hi, I'm very new to SQL server and fairly new to Visual Basic,I've a small newtwork that I've access to, on one pc is SQL server 2000, and on several others VB is installed, my question is, I've written an extremely simple program in VB which connects to the server and reads one of the databases on it, the program works on all the pc's on the network bar one, the server itself. I've included the connection string I've used in my program below
constr = "Provider=SQLOLEDB.1;Password=1234;User ID=dave;Initial Catalog=mydata;Data Source=192.168.0.10"
I've been told that if you want to connect to the server while actually on the server then the Data Source is different, but nobody seems to know what it should be, can anyone help?
August 28, 2005 at 2:33 pm
Try 127.0.0.1 or try "(local)" instead of the IP.
Aunt Kathi Data Platform MVP
Author of Expert T-SQL Window Functions
Simple-Talk Editor
August 29, 2005 at 6:47 am
you could also try the server name for all machines;
constr = "Provider=SQLOLEDB.1;Password=1234;User ID=dave;Initial Catalog=mydata;Data Source=SERVERNAME;"
that should work in all situations, because your WINS server on the network will translate the SERVERNAME to 192.168.0.10 for your other machines.
technically, it would be slightly slower than putting in the IP address, because of the DNS/ WINS lookup, but would be better if that server's address would change at all in the future.
Lowell
August 29, 2005 at 7:43 am
many thanks for the help, using the IP address 127.0.0.1 didn't work, but using the servername did, although like you said a bit slow. Thanks again
September 8, 2005 at 9:04 am
I keep this site bookmarked:
http://www.connectionstrings.com/
Sql Server.
OLE DB, OleDbConnection (.NET) (Try these , even if you're in VB6 )
Use the ODBC ones as a last resort, since that introduces an extra "layer" into the connection/communication process.
September 9, 2005 at 2:12 am
that's great, I've book marked that page for future reference, many thanks
September 13, 2005 at 1:17 pm
I am sorry in .NET you don't use OLEDB to connect to SQL Server you use ADO.NET, OLEDB is for Access and Excel. Try the link below for a SQL Server connection tutorial for Asp.net 2.0. Hope this helps.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000010.asp
Kind regards,
Gift Peddie
Kind regards,
Gift Peddie
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply