connecting to sql server?

  • 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?

  • 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

  • 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • 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

  • 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.

  • that's great, I've book marked that page for future reference, many thanks

  • 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