Results 1 to 7 of 7

Thread: Trying to understand the ADO.NET connection string

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982

    Trying to understand the ADO.NET connection string

    I found an example of a connection string on GoDotnet http://samples.gotdotnet.com/quickst...ldtreader.aspx . But I am having difficulty understanding the connection string. With ADODB I would usully use the following connection string.
    Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Database ;Data Source=Server
    The connection string in the example is as follows
    VB Code:
    1. Dim mySqlConnection as SqlConnection = new SqlConnection("server=(local)\VSdotNET;Trusted_Connection=yes;database=northwind")
    The bit I don't understand is
    server=(local)\VSdotNET
    How do I change this to point at the SQL server on the network when I am developing on my local machine?


    Things I do when I am bored: DotNetable

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    In exactly the same way you would with standard ADO! I tend to connect using the server ip address and port number myself:

    "Data Source=255.255.255.0,1400; Network Library=DBMSSOCN; Initial Catalog=SQLServerDBName; UID=SQLServerUserName; pwd=AnyOldPassword"

    You can always use the .Net server explorer or a udl file to create the connection string as well: http://www.vbforums.com/showthread.p...&highlight=udl

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    When I use the following connectionstring

    Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Database ;Data Source=Server

    I get the following error (as attached)

    I have never used this style connectionstring with ADODB so I do not know how to change it.
    server=(local)\VSdotNET;Trusted_Connection=yes;database=northwind
    Attached Files Attached Files


    Things I do when I am bored: DotNetable

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Try adding the user name & password bit as above to your connection string...

    UID=SQLServerUserName; pwd=AnyOldPassword

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    I will only make a successful connection when I use the sa userid and password. I can use my userid and password to connect through SQL Analyser and Enterprise manager but it will fail when added to the connection string.


    Things I do when I am bored: DotNetable

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    We don't really want to be passing passwords around.
    Our plan is to use integrated security.


    Things I do when I am bored: DotNetable

  7. #7
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    This works on my SQL database:
    VB Code:
    1. Dim mySqlConnection as SqlConnection = new SqlConnection("server=(local);trusted_connection=true;database=northwind")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width