"Login failed for user 'sa'" datagrid control - SqlDataAdapter

J

Jerry Higgins

I added a SqlDataAdapter to a web form, created a data
connection, and generated a dataset. I then connected it
to a DataGrid control. When I do this using the
SqlServer database on my machine everything works fine.
When I do it using a SqlServer database on another
machine I get the "Login failed for user sa" error.
However, when I right click on the SqlDataAdapter and
click "Preview Data" it brings back the data OK. Why
would it bring back the data on this but not work in the
DataGrid control?

Thanks,

Jerry
 
G

Guest

I can connect fine through SQL Enterprise manager. Also,
as I mentioned in the post, I can right click on the
SqlDataAdapter and read the data fine.
 
C

Curt_C [MVP]

is this where the server that you are publishing to? or do you mean locally
even?
Try IP instead of NAME for server also
 
C

Chris Botha

Jerry, when using Enterprise Manager or right clicking on the
SqlDataAdapter, you are logged in as yourself, through the Web form, you
connect as the ASP.NET user. I would examine the "Login failed for user sa"
a bit closer, sounds like it can be true.
 
G

Guest

I see what you are saying but not sure how to resolve
it. In order to get this to work on my machine I had to
add ASPNET as a user in the SQL Server database on my
machine. When I try to add ASPNET as a user in SqlServer
on the other machine I get the error

"Error 15401: Windows NT user or
group '<machinename>\ASPNET' not found. Check the name
again."

Thanks,

Jerry
 
J

Jerry Higgins

I'm not sure I understand. I don't think I'm publishing
to a server. I am simply trying to read the data out of
a database on another machine and display it in the
grid. When I get the data from my machine
(locally) everything is fine. Do you mean change the
name of the server in the connection string to and IP
address? I can try that. I'm still wondering why I can
get the data from the SqlDataAdapter but not the grid.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top