Sql connection from VB.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sport Girl
    New Member
    • Jul 2007
    • 42

    Sql connection from VB.net

    Hi everybody,

    please can anybody give me a hand;

    i writed the syntax to connect from a vb.net 2008 windows form application to an SQL dataabse 2005, but the problem is that whenever i run the form i get :

    Login failed for user 'sa'. The user is not associated with a trusted SQL Server connection.

    Code:
    SqlConnection.ConnectionString = "Server=owner;database=***;user id=sa; password=***"
    Please, can anybody give me an idea if i should create a new user for authentication and how, how to make the ODBC connection ... The procedure to realise the connection that is not relative to script writing in vb.net

    Regards
  • balame2004
    New Member
    • Mar 2008
    • 142

    #2
    Originally posted by Sport Girl
    Hi everybody,

    please can anybody give me a hand;

    i writed the syntax to connect from a vb.net 2008 windows form application to an SQL dataabse 2005, but the problem is that whenever i run the form i get :

    Login failed for user 'sa'. The user is not associated with a trusted SQL Server connection.

    Code:
    SqlConnection.ConnectionString = "Server=owner;database=***;user id=sa; password=***"
    Please, can anybody give me an idea if i should create a new user for authentication and how, how to make the ODBC connection ... The procedure to realise the connection that is not relative to script writing in vb.net

    Regards

    I think server name, database and passoword did not match.

    Do you know server name, database, existing username as well as password?

    First of all check that you have installed Sql Server management studio or not?. If not, download and install management studio(from www.msdn2.micro soft.com-SqlServer - Downloads). Now you can check your sql server 2005 database server.

    Open Sql Server Management Studio from Start->Programs->Sql Server 2005 and you can see there your Sql Server name something like "SqlExpress\MyS qlServer".

    If you don't know password, connect with Windows Authentication mode. Once you have connected your sql server through management studio you can see your database under databases shown in the browser tree.

    For example if your slq server is "SqlExpress\MyS qlServer" and database is "TestDB" you should use the below code.

    Code:
    'Connection string to connect database in windows authentication mode.
    SqlConnection.ConnectionString = "Server=SqlExpress\\MySqlServer;database=TestDB;Integrated Security=True"

    Let me know if you have any questions.

    - Balaji U

    Comment

    • Sport Girl
      New Member
      • Jul 2007
      • 42

      #3
      Thank u. I used your syntax and it worked.

      Comment

      Working...