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!

sql string for vb.net and asp.net different??

Status
Not open for further replies.

Schimsky

Programmer
Oct 4, 2003
23
0
0
US
Hi,

I'm really new to sql server. I just installed MSDE 2000 on our company's network server. Then I quickly wrote a VB.Net program to access a database on the server. I used this code:

Dim objConn As New SqlConnection("workstation id=steve;packet size=4096;integrated security=SSPI;data source=SQLSERVER;persist security info=False;initial catalog=TXNIC")

Dim objCommand As New SqlCommand
Dim objDa As New SqlDataAdapter
Dim objDs As New DataSet

objCommand.CommandText = "Select * From Candidates"
objCommand.Connection = objConn
objDa.SelectCommand = objCommand
objDa.Fill(objDs, "Table1")
MessageBox.Show(objDs.Tables("Table1").Rows(10).Item("LastName"))
objConn.Close()

The above Code Worked perfectly!!!

Then I took the same code as above, (except for the Messagebox line), and placed in an ASP.Net web page. It bombed with this error:

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

Does anyone know how to fix this?

Thanks.

Steve
 
that's probably because the vb app is using integrated security, i.e., who you logged into your computer as. ASP is probably using the iuser (or something like that) account, who is logged into the ASP session. You can fix it by hardcoding the username/password into your app, or just assigning the iuser account to have access to your db... or changing the sessions username/password.
 
despierto is correct. The problem is because you are attempting to log into the SQL Server with an account that doesn't exist on the SQL Server.

There are three ways to resolve this.

1. Create a SQL Account in the database and hard code that into the connection string in the ASP app.

2. Setup the Web Server to run under a specific Windows account on the domain, and make sure that account has access to the SQL Server.

3. Setup the Web Server to require authintication. That will log the user into the database using what ever creditentials they logged into the Web Site with.


Denny

--Anything is possible. All it takes is a little research. (Me)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top