hi everybody! I am just a beginner in asp.net.
i am trying to connect to the sql server and getting an error:
Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
the code line for connection is :cn.ConnectionString = "Data Source=DENVER; Initial catalog=pubs; user id=sa ; Pwd="
right click on the server name - properties gives a message saying only sysadmin can access this feature.
do i need to change something in code please help.

unable to connect to SQL server
Mark Bower
sa is the system account; do you have access to that account and is it a blank password Also, if logging in with a sql account, it may help to add integrated security=false so it doesn't use windows integrated security, though I don't know if that is the problem. If you want to use a SQL account, create an account with the rights you need it to do (such as grant it the datareader/datawriter).
Brian
mvarblow
ASPNET account only works when you set Integrated Security=true; so you can't log into QA with the sa account Are you sure that the password is correct Also, did you try that other SQL account you created, and does that work in QA and the web portion, now that mixed authentication is enabled
Manotas
Then give it the permissions to database (you can even specify which tables your application must access)
Good luck..
Skinny
Eias Nabhan
Hey,
Are you having these problems in SQL Server, or through the application Are you connecting to the other DBs using the sa account also
You can create a new SQL Server user to try this by doing this:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/howtosql/ht_6_secrty_68c9.asp
http://msdn.microsoft.com/library/default.asp url=/library/en-us/howtosql/ht_6_secrty_4249.asp
Try a new SQL Server user, give the appropriate permissions you need, and try that. What all is your application doing Now also, is the pubs database you are using is that on your lcoal machine, or on the server
TKTOCK
Yes, Ok, you should add Integrated Security=false to the connection string. Check with the sysadmin that mixed security is enabled. You can verify by trying to log into SQL Server query analyzer into that database with the sa account credentials. If you can't get in, mixed security isn't enabled, and that is your problem.
You can't use your credentials in the user id and password connection string properties, because those are only sql accounts (integrated security=true uses your domain account, but the problem is in an ASP.NET application, it uses the MACHINENAME\ASPNET account to log on with).
Brian
aaarrr
the code is very simple:
Public
Class DataViewPage Inherits System.Web.UI.Page Protected WithEvents dgView As System.Web.UI.WebControls.DataGrid Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cn As New SqlClient.SqlConnection Dim adapt As New SqlClient.SqlDataAdapter Dim cmd As New SqlClient.SqlCommand Dim ds As New DataSetcn.ConnectionString = "Server=DENVER; Database=pubs;User Id=sa ; Pwd= "
cn.Open()
cmd.CommandText = "Select * from authors"
cmd.Connection = cn
cmd.CommandType = CommandType.Text
adapt.SelectCommand = cmd
adapt.Fill(ds, "authors")
dgView.DataSource = ds.Tables("authors").DefaultView
dgView.DataBind()
cn.Close()
End SubEnd
Class**///
i was not able to create a new user name and asked our sysadmin. he did that and checked all my permissions. he said everything should be good now but I still cannot open the connection even under another user name, with or without a password.
I tried to use my personal user name with my company's database and got the same result.
pubs database is under Denver(windows NT) server, it's not on my local machine. this is the only server that is listed under SQL Server Group when i open Enterprise Manager.
David A. Coursey
pubs is a test database that i believe came with SQL server. I can add users to other databases (just do right click and add a new user) but it doesn't work for this database. i don't see the choice of adding a new user. The "pubs" database and "sa" user are used in the learning course i am using so i thought it supposed to work....
PremSamuel
I added Integrated Security=false and it didn't help.
i opened QA, changed Widows Authentication to SQL server authentication and tried to log in with my login name and password. it didn't work.
I asked our sysadmin yesterday and gave printed instructions what needs to be done. He said it was done. i'll talk to him again.
Thank you again. i have no one here to ask about asp.net.
Tom_MTB
d_Sun
when i do right click on Users, add a new user, i have a choice of creating a new user NAME and new user LOGIN NAME.
Both need to be created but Login name gives me a dropdown box with other login names (selecting one of them gives an error that "\" in mymachine\aspnet Name is not valid char) and doesn't let me create a new LOGIN name saying i need to be logged as admin.
our sysadmin created under pubs - users a new user login mymachine\myname yesterday with all permissions. I don't understand why i need to create another one.
the server i am trying to connect is a remote server. I don't have a local server installed
dba72
J Garcia ARB
mixed authentication is surely enabled! I saw it!
Since my sql connection is still not working I temporary work with MS Access db.
my question now is: How do I connect to SQL server without hardcoding user id and password
there sould be a way to do it since I can't give every users who is going to use my programs all rights in sql database.
I looked at the code of a guy, who worked here before I came, and tried to figure out how he connected to database.
he used some appication settings like :
<
add key="domain" value="XXXXXXXX==" /> <add key="server" value="jYgPuMrXXXXXXxuS7sPYg==" /> <add key="database" value="rODOXXXXXXX==" />and nothing else : no names, no passwords, no IP's in entire files code. i wonder if it's the way he connected and i can use it or i am missing something.
amirmira
I had almost the same problem last week & Ken helped me out, it worked like magic THANX again Ken Turker
Try this
Open up the database's properties you will find users in there , add the aspnet account as a user for the database e.g. (machinename\aspnet) then give it permissions to access the database
Check out my post
unable to access SQL server from web app(Skinny)
rswipe
1. when i go to pubs-properties-permissions i see 2 user/roles: me and public (permissions given for everything)
2. when i open Users under pubs: i see 2 users: 1: name "dbo", login name "sa", database access-permit, and second user has my name as a name, login as mymachine\myname and access -permit.
i tried to login both: as "sa" and as "mymachine\myname". still not working.
our sysadmin is my last hope.