hiii all,
iam doing a project in asp.net and the back end is sql server.
so when i tried the connection code it gives me an server error
"Cannot open database "C:/Program Files/Microsoft SQL Server/MSSQL.1/MSSQL/Data/projdb.mdf" requested by the login. The login failed.
Login failed for user 'YOGESH\Owner'.

"

Recommended Answers

All 4 Replies

Vizy,
iam using windows authentication in the project so sql username and password are not involved....
I tried ur idea of connection string and mah problem is almost solved..but still an exception is gettin occured.
i guess dis tym der is a problem in mah code.
so following is mah code:

Dim constr As String
             constr = "Data Source=YOGESH\SQLEXPRESS;Initial Catalog=projdb;Integrated Security=True"
        Dim conn As New SqlConnection(constr)
        Dim cmd As New SqlCommand(constr, conn)
        Dim rd As SqlDataReader
        cmd.CommandText = "select * from employee where emp_name='txtname.text'"
        conn.Open()

        Try
            rd = cmd.ExecuteReader()
            GridView1.DataSource = rd
            GridView1.DataBind()
            rd.Close()
            conn.Close()
        Catch ex As Exception
            MsgBox("exception occured:", MsgBoxStyle.Critical)
            MsgBox.show(ex.Message, MsgBoxStyle.Critical)

        End Try

basicallly iam tryin to fetch the details of the employee whose name is entered in the textbox of the form from the database and display the same in a gridview
so after entering the name when i click the submit button an exception stating"exception occured" is gettin displayed..
plzzzzz suggest the changes..

thanxx for ur reply.

hi, I faced below problem retrieving the data from sqlserver . How to solve this problem

An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code

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

hi,

try like this

constr = "Data Source=YOGESH\SQLEXPRESS;Initial Catalog=projdb;Integrated Security=false"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.