Link to home
Start Free TrialLog in
Avatar of SirReadAlot
SirReadAlot

asked on

Login failed for user 'SKYNET\IUSR_SKYNET'.

Hi experts,

I got the above error while running this code--
 Private Shared Function Connection() As SqlConnection
        Dim conHalloween As New SqlConnection
        Dim sConnectionString As String _
         = "Data Source= SKYNET;" _
        & "Initial Catalog=Halloween;" _
            & "Integrated Security=SSPI"
        conHalloween.ConnectionString = sConnectionString
        Return conHalloween
    End Function


I have changed the security setting in my sql server to read both windows and sql authentications


how do i solve the above error pls.

thanks guys
Avatar of Kinger247
Kinger247

Try :


    Private Shared Function Connection() As SqlConnection
        Dim conHalloween As New SqlConnection
        Dim sConnectionString As String = & _
            "Data Source= SKYNET;" & _
            "Initial Catalog=Halloween;" & _
            "Integrated Security=SSPI"
        conHalloween.ConnectionString = sConnectionString
        Return conHalloween
    End Function
is that your problem ???
your question seems to be different yet the code won't work anyway ..
Avatar of SirReadAlot

ASKER

i will try it
Have you granted the IUSR_SKYNET local user access to the database? You are using integrated security, so it will connect in the context of the user. Either grant access to the local user account, connect with a SQL login account or use windows authentication and impersonation to connect to the SQL Server.
conHalloween.ConnectionString = sConnectionString

saying sConnectionString is not declared
Avatar of YZlat
how do i grant the access
okay, it works i granted the user


thanks
ASKER CERTIFIED SOLUTION
Avatar of Nightman
Nightman
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK, you're ahead of me ;)

Note that best practice for security is to use windows authentication with impersonation, either connecting as the user that is connecting to the site or impersonating a specific domain account (you would set this up in the web.config) .

Next best would be to use a specific SQL login and use that in your connection string.