Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO.Net SQL Server Connection issue 1

Status
Not open for further replies.

CassidyHunt

IS-IT--Management
Jan 7, 2004
688
0
0
US
I am trying to log into a local SQL Server database I have created on my machine. I kept everything pretty much default for sa no password that sort of thing. I can log into other database instances that I setup early no problem. This one just does not seem to work.

I get

Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.

Here is my code
Code:
 Private Function GetEmployeePhoto() As String
        Dim EmployeePhotoPath As String
        Dim i As Integer
        Dim cn As New System.Data.SqlClient.SqlConnection("Server=INTEL925-01;Database=LNH;UID=sa;PWD=;Trusted_Connection=no")
        Dim cm As New System.Data.SqlClient.SqlCommand
        Dim sda As New System.Data.SqlClient.SqlDataAdapter(cm)
        Dim ds As New System.Data.DataSet

        cm.CommandText = "GetRandomEmployeePhoto"
        cm.CommandType = Data.CommandType.StoredProcedure
        cm.Connection = cn

        Try
            sda.Fill(ds, "WebTemp")
            i = CInt(ds.Tables("WebTemp").Rows(0).Item("id").ToString)
        Catch ex As Exception
            Throw ex
        End Try

        cm.CommandText = "Select EmployeePhotoLocation from EmployeePhotos where EmployeeID = " & i
        cm.CommandType = Data.CommandType.Text

        Try
            sda.Fill(ds, "EmployeePhotoPath")
            EmployeePhotoPath = ds.Tables("EmployeePhotoPath").Rows(0).Item("EmployeePhotoLocation").ToString
        Catch ex As Exception
            Throw ex
        End Try
        
        Return EmployeePhotoPath

    End Function

Thanks

Cassidy
 
in my App.Config are the SQLserver settings like this :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key ="SQLserver" value ="integrated security=SSPI;server=QUAL-PC01\QUALITYSOFTWARE;persist security info=False;initial catalog=Q-Cycle"></add>
<add key ="ReportServer" value ="QUAL-PC01\QUALITYSOFTWARE"></add>
<add key ="DataBase" value ="Q-Cycle"></add>
<add key ="StandaardPrinter" value ="EPSON AL-C1000"></add>
</appSettings>
</configuration>



Eric De Decker
eric.de.decker@pandora.be

 
Still get the same error. I am thinking it might be a permission issue on executables in the database but not sure.

Any ideas?
 
What version of SQL server you works ?

If it is 2000 then you most after de servername the servernamaspace like : QUAL-PC01\QUALITYSOFTWARE (you can see this in the interprise manager wat the spacename is)

Have you make a windows User ?

SQL server 7.0 connection like this :

server=localhost;Database=Q-Cycle;Integrated Security=SSPI



Eric De Decker
eric.de.decker@pandora.be

 
I am using SQL SErver 2000 and I just got it up and working. I figured out that I didn't now grant permission on the local machines anonymous account to do what I want.

This is actually an N-Teir component that I use in a webpage and windows application.

You were right about the connection string to. Thank you for the help.

Cassidy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top