connection to SQL Server

  • Hi,

    I am trying to connect to the LOCAL database on my pc from VB.NET and the code is quite (Visual) basic but keep getting an error message

    quote:


    login failed for user 'test' Reason:- not associated with a trusted SQL Server connection


    - I tried using both Windows authentication and SQL Server authentication in vain. Can some one please help me out?

    Thanks in advance

     
    
    dim conn as sqlclient.sqlconnection
    dim strconn as string
    try
    conn = new sqlclient.sqlconnection()
    strconn &= "Data source=(local);"
    strconn &= "Initial catalog = Northwind;"
    strconn &= "User ID = test;"
    strConn &= "password=test;"

    conn.connectionstring=strconn
    conn.open()

    catch oExcept as exception
    messagebox.show("Error")

    end try

  • Is your local server set for SQL Authentication?

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

  • If you go to Enterprise MAnager you can ccheck "Registered sQL server properties" and see if you have windows authentication or SQL Server authentication. Your code requires SQL Server authentication.

    Try this code:

    dim conn as sqlclient.sqlconnection

    try conn = new sqlclient.sqlconnection("Server=(local);UID=test;PWD=test;Database=Northwind")

    conn.open()

    catch oExcept as exception

    messagebox.show("Error")

    end try

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply