Results 1 to 15 of 15

Thread: Vb.net App - SQL Database Login

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    59

    Vb.net App - SQL Database Login

    I have a vb.net app connecting to a sql database.

    When I run the app on the PC running Sql Server it logins ok.

    When I try and run the app on a different PC, I get the following error
    System.Data.SqlClient.SqlException: Login failed for user 'BM-PC\Guest'.

    I am using the following connection string

    Dim connstring As String = "server=BM-PC;Initial Catalog=EquinexMasterSql;User ID=username;Password=password;Trusted_Connection=False;"

    It looks like the users, login and database security is configured correctly
    in Sql Server Management Studio.

    Any suggestions are most welcome.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Vb.net App - SQL Database Login

    I have a feeling that you've configured your SQL Server database to accept windows authentication rather than SQL Authentication. I also think that you may be making a web application rather than a "vb.net app" but that may be a moot point. You should look at your authentication settings on your SQL Server database.

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    59

    Re: Vb.net App - SQL Database Login

    I checked my sql authentication and its set to accept both windows and sql authentication.

    My application is definitely a win forms application.

    Silly question but is it necessary to install sql client software on the PC, or does my vb.net app not require this.

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

    Re: Vb.net App - SQL Database Login

    Do you have something like EXCEL on that same workstation that is giving you the login to GUEST error message??

    *** 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
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Vb.net App - SQL Database Login

    The client softwear should be installed. Are you using the SQL Native client driver? The SQL Server driver is included with XP.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

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

    Re: Vb.net App - SQL Database Login

    But you don't need to install client software (like management studio or query analyzer) in order to run VB-client side apps against a remote DB.

    I was asking if you had something like EXCEL on the client box so you could try to connect to the server/db with EXCEL and see what error popped up in that case.

    *** 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
    Member
    Join Date
    Feb 2006
    Posts
    59

    Re: Vb.net App - SQL Database Login

    I tried logging in to Sql through Excel with the following code but I get the following error - Login failed for user 'BM-PC\Guest'

    I'm not sure where I type the username and password in my Excel VBA code.

    Code:
    Sub DataExtract()
    ' Create a connection object.
    Dim cnPubs As ADODB.Connection
    Set cnPubs = New ADODB.Connection
    
    ' Provide the connection string.
    Dim strConn As String
    
    'Use the SQL Server OLE DB Provider.
    strConn = "PROVIDER=SQLOLEDB;"
    
    'Connect to the Pubs database on the local server.
    strConn = strConn & "DATA SOURCE=BM-PC;INITIAL CATALOG=EquinexMasterSql;"
    
    'Use an integrated login.
    strConn = strConn & " INTEGRATED SECURITY=sspi;"
    
    'Now open the connection.
    cnPubs.Open strConn
                
    End SubSub DataExtract()
    ' Create a connection object.
    Dim cnPubs As ADODB.Connection
    Set cnPubs = New ADODB.Connection
    
    ' Provide the connection string.
    Dim strConn As String
    
    'Use the SQL Server OLE DB Provider.
    strConn = "PROVIDER=SQLOLEDB;"
    
    'Connect to the Pubs database on the local server.
    strConn = strConn & "DATA SOURCE=BM-PC;INITIAL CATALOG=EquinexMasterSql;"
    
    'Use an integrated login.
    strConn = strConn & " INTEGRATED SECURITY=sspi;"
    
    'Now open the connection.
    cnPubs.Open strConn
                
    End Sub

  8. #8
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Vb.net App - SQL Database Login

    Is BM-PC\Guest and actual SQL Server Login Name? or is this a user on the PC
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

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

    Re: Vb.net App - SQL Database Login

    I wanted you to use EXCEL to connect like this...

    If you have office 2003...

    Go into EXCEL - Menu Data>Import External Data>Import Data

    Pop-up appears with Select External Data source - and +New SQL Server Connection.odc should appear.

    The rest should be pretty obvious...

    *** 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

  10. #10

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    59

    Re: Vb.net App - SQL Database Login

    Quote Originally Posted by GaryMazzone
    Is BM-PC\Guest and actual SQL Server Login Name? or is this a user on the PC
    BM-PC is the name of the server running SQL, in my app I've hard coded the login but it tries to login as Guest rather then what is hard coded in the app.

    Quote Originally Posted by szlamany
    I wanted you to use EXCEL to connect like this...

    If you have office 2003...

    Go into EXCEL - Menu Data>Import External Data>Import Data

    Pop-up appears with Select External Data source - and +New SQL Server Connection.odc should appear.

    The rest should be pretty obvious...
    I've managed to get Excel to connect to my Sql database using the SQL username and password.

  11. #11
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Vb.net App - SQL Database Login

    You need to pass a user (login) that is stored in the SQL server Logins folder to this to work, unless of course you are in a domain and domain rights are correct. You don't pass the user of the OS.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  12. #12

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    59

    Re: Vb.net App - SQL Database Login

    In my vb.net App I login with the following details, this lets me login when I'm using BM-PC but not when I am at a remote PC.

    Surely if this information wasn't in the Sql server logins folder then I shouldn't be able to login from BM-PC either.

    Public connstring As String = "server=BM-PC;Initial Catalog=EquinexMasterSql;User ID=Username;Password=Password;Trusted_Connection=False;"

  13. #13
    New Member
    Join Date
    Oct 2011
    Posts
    5

    Re: Vb.net App - SQL Database Login

    I know this is an old thread but I'm having the same issue, was this ever resolved?

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

    Re: Vb.net App - SQL Database Login

    Welcome to the forum!

    Best to start a new thread - show your code and your connection string - and give your specific error message.

    No reason to bury your question in this thread.

    *** 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

  15. #15
    New Member
    Join Date
    Oct 2011
    Posts
    5

    Re: Vb.net App - SQL Database Login

    Quote Originally Posted by szlamany View Post
    Welcome to the forum!

    Best to start a new thread - show your code and your connection string - and give your specific error message.

    No reason to bury your question in this thread.
    thanks, I will do that...

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