Results 1 to 16 of 16

Thread: [Resolved] Connection Strings ?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    27

    Exclamation [Resolved] Connection Strings ?

    hello everyone,

    can some one please explain to me connection string because i see alot of it in the code (put your connection string) and in my case im using Visual Basic 2010 and i need to connect it to Data.SqlClient.Sqlconnection, i heard that my string should look like this:

    ("server=*****;Port=3306; User ID=*****; password=****; database=*****")

    but I don't know what I should put in server, userid, password and the database.

    first of all what i should type in "server" ?
    and for the userid and the pass, is it me choosing it or there is a known userid and pass i have to put!?

    I know my questions are stupid but i really need your help

    btw my db name is : Database1.sdf

    thanks
    Last edited by Jack Tomy; Jan 20th, 2012 at 05:10 PM.

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Connection Strings ?

    sdf makes it look like SQL CE - is that so?

    Go to connectionstrings.com and you will get good examples...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    27

    Re: Connection Strings ?

    yes szlamany i went to connetionstings.com, i told u that my connections string look like this :

    Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

    but i dont know what i must put in server, database, username and password !


  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Connection Strings ?

    That all important question I asked...

    sdf makes it look like SQL CE - is that so?

    [edit] CE - compact edition... [/edit]

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    27

    Re: Connection Strings ?

    i really dont know what you mean with ur question, im not expert in VB.NET
    but i can tell that it gives me this error :

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

    what i realized that the program cannot reach the db, so i said that the problem maybe from the connection string


  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Connection Strings ?

    Do you have MS SQL Server - which is an additional product - running on your machine?

    Normally a .SDF is a MS SQL COMPACT EDITION file - there is connection strings for that here

    http://connectionstrings.com/sql-server-2005-ce

    And it uses a different namespace for access...

    You need to tell us what you are using.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    27

    Re: Connection Strings ?

    oh okay just a moment i'll check

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    27

    Re: Connection Strings ?

    yes acually its :

    Microsoft SQL Server Compact 3.5

    i had my friend he told me that Microsoft SQL Server Compact 4.0 is realesed !

    should i get it or smthing ?

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    27

    Re: Connection Strings ?

    i think that i dont have MS !

    also i m not using access db.

    [Edited] im using Data.SqlClient.Sqlconnection, the link* u gave me is for: System.Data.SqlServerCe.SqlCeConnection [Edited]

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    27

    Re: Connection Strings ?

    szlamany i know what is my connection sting, i know what i m using and i already notify that im using this connection string :

    Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

    but i told u that i dont know what i must type in server place? should i type localhost or what ?
    and about the username and password , what i should type , is it me who will choose user and pass?

  11. #11
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Connection Strings ?

    You are using connection strings for MS SQL SERVER

    This is the link for MS SQL CE

    http://connectionstrings.com/sql-server-2005-ce

    See how they don't ask for a SERVER but instead a DATASOURCE??

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    27

    Re: Connection Strings ?

    ummm okay, sorry for being stupid !!

    anyways my connection string now looks like this :
    Data Source=C:\Users\Houssin\Documents\Visual Studio 2010\Projects\sqlclient\sqlclient\Database1.sdf;Persist Security Info=False;


    but i still got this error :

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)


  13. #13
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Connection Strings ?

    Now that you have the correct connection string - you have to use the correct namespace

    System.Data.SqlServerCe.SqlCeConnection

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    27

    Re: Connection Strings ?

    okay i will use it and reply u just a moment

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Jan 2012
    Posts
    27

    Re: Connection Strings ?

    Perfectly worked!!
    Thanks a lot szlamany for helping me solve this problem


  16. #16
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Connection Strings ?

    No problem - easy to be confused with the different name spaces and what not!

    Mark your thread resolved! [edit] I see your already did [/edit]

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

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