|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ADO.NET help - Filling a DataGrid with contents of a DataSetAs a relative newbie to SQL Server/ASP.NET I'm hoping someone here can help with my problem. I'm developing a timesheet application in ASP.NET C# using Visual Studio 2003 with a database built in MSDE. One of my forms needs to return a simple list of resources from my database. I have followed the guide on the MSDN libraries, but for some reason I continuously get the same error message. What I've done so far is Create the database, tables, and populate with some sample data using using Server Explorer in Visual Studio. I have connected to the database (using integrated security) and I am trying to get the contents of the Resource table to appear on my form. I have then created a DataAdapter (tested the connection, set the SQL as a simple SELECT * from Resource, etc), which also generates an sqlConnection for me. To test this I have previewed the generated data, and it returns what I want, so I have chosen to generate a DataSet of this (dsResource). I am then trying to get this data into a simple DataGrid. On the properties of the DataGrid I have changed the DataSource to point at my Dataset. As I understand it, I then have to add the following to my Page Load section of my code. sqlConnection1.Open(); this.sqlDataAdapter1.Fill(this.dsResource); sqlConnection1.Close(); The form builds fine, but when I browse to the particular form I get the following error for the sqlConnection1.Open(); line Exception Details: System.Data.SqlClient.SqlException: Cannot open database requested in login 'SCMS'. Login fails. Login failed for user 'AL-NOTEPAD\ASPNET'. To me this is an error with my connection string. My database instance is actually 'AL-NOTEPAD\VSDOTNET'. However the properties for sqlConnection1 are pointing to the correct datasource. I do not know why the application is looking for user 'AL-NOTEPAD\ASPNET'. It does not exist, to my knowledge. Any help with this would be greatly appreciated, as I get the same error with my code for forms-based login... Thanks in advance.. Yeah, You need to open up enterprise manager for the SQL Server and add your
ASPNET account to the database your are trying to connect to. HTH Show quote "thebison" <alex.sincla***@btinternet.com> wrote in message news:1139066561.202974.237410@g44g2000cwa.googlegroups.com... > Hi, > > As a relative newbie to SQL Server/ASP.NET I'm hoping someone here > can help with my problem. I'm developing a timesheet application in > ASP.NET C# using Visual Studio 2003 with a database built in MSDE. > One of my forms needs to return a simple list of resources from my > database. I have followed the guide on the MSDN libraries, but for > some reason I continuously get the same error message. > > What I've done so far is Create the database, tables, and populate > with some sample data using using Server Explorer in Visual Studio. I > have > connected to the database (using integrated security) and I am > trying to get the contents of the Resource table to appear on my > form. I have then created a DataAdapter (tested the connection, set > the SQL as a simple SELECT * from Resource, etc), which also generates > an sqlConnection for me. To test this I have previewed the generated > data, and it returns what I want, so I > have chosen to generate a DataSet of this (dsResource). I am then > trying to get > this data into a simple DataGrid. On the properties of the DataGrid > I have changed the DataSource to point at my Dataset. As I > understand it, I then have to add the following to my Page Load > section of my code. > > sqlConnection1.Open(); > this.sqlDataAdapter1.Fill(this.dsResource); > sqlConnection1.Close(); > > The form builds fine, but when I browse to the particular form I get > the following error for the sqlConnection1.Open(); line > > Exception Details: System.Data.SqlClient.SqlException: Cannot open > database requested in login 'SCMS'. Login fails. Login failed for > user 'AL-NOTEPAD\ASPNET'. > > To me this is an error with my connection string. My database > instance is actually 'AL-NOTEPAD\VSDOTNET'. However the properties > for sqlConnection1 are pointing to the correct datasource. I do not > know why the application is looking for user 'AL-NOTEPAD\ASPNET'. It > does not exist, to my knowledge. > > Any help with this would be greatly appreciated, as I get the same > error with my code for forms-based login... > > > Thanks in advance.. > Hi Terry, thanks for replying so promptly.
A quick question, as my DB is going to be fairly small and is more a prototype application, I am using MSDE and only have that installed. This does not come with enterprise manager. Can i get hold of this seperately, or do you know of another way I can add the ASPNET account to the database? Thanks again.. On 4 Feb 2006 07:22:41 -0800, "thebison"
<alex.sincla***@btinternet.com> wrote: [snip] >Exception Details: System.Data.SqlClient.SqlException: Cannot open Check your web folder's user permissions in IIS. It looks to me as>database requested in login 'SCMS'. Login fails. Login failed for >user 'AL-NOTEPAD\ASPNET'. > >To me this is an error with my connection string. My database >instance is actually 'AL-NOTEPAD\VSDOTNET'. However the properties >for sqlConnection1 are pointing to the correct datasource. I do not >know why the application is looking for user 'AL-NOTEPAD\ASPNET'. It >does not exist, to my knowledge. though you have your web site anonymous user set to ASPNET and you haven't given that user permissions on your database. Otis Mukinfus http://www.otismukinfus.com http://www.tomchilders.com Otis,
Thanks for replying, as I'm still quite new to Visual Studio and ASP.NET, how do I check the webfolder's user permissions in IIS? Regards Al On 4 Feb 2006 11:30:54 -0800, "thebison"
<alex.sincla***@btinternet.com> wrote: >Otis, 1. Right Click on the "My Computer" icon on your desk top or in the> >Thanks for replying, as I'm still quite new to Visual Studio and >ASP.NET, how do I check the webfolder's user permissions in IIS? > >Regards > >Al menu 2. From the resulting context menu, choose "Manage" 3. When the "Computer Management" window appears, click the plus sign on "Services and Applications" 4. Click the plus on "Internet Information Services" 5. Open the "Web Sites" folder and the "Default Web Sites" folder. 6. Choose you web site from the web sites shown by right clicking it and choose "Properties" from the context menu. 7. Click the "Directory Security" tab, then click the "Edit" button. 8. There are two possibilities here... You may see that the anonymous user is set to "IUSR_YOURMACHINENAME" or "ASPNET". Which ever of the settings you see there is the user your database must have a logon for. In your case it appears that you will find it to be "ASPNET". Set the permissions on your database objects accordingly... Otis Mukinfus http://www.otismukinfus.com http://www.tomchilders.com In web application, when you use integrated security connection, you are
using ASPNET account. You can change in Framework machine.config from userName="machine" // ASPNET to userName="SYSTEM" // localsystem (high privilege admin) HTH Elton Wang Show quote "thebison" wrote: > Hi, > > As a relative newbie to SQL Server/ASP.NET I'm hoping someone here > can help with my problem. I'm developing a timesheet application in > ASP.NET C# using Visual Studio 2003 with a database built in MSDE. > One of my forms needs to return a simple list of resources from my > database. I have followed the guide on the MSDN libraries, but for > some reason I continuously get the same error message. > > What I've done so far is Create the database, tables, and populate > with some sample data using using Server Explorer in Visual Studio. I > have > connected to the database (using integrated security) and I am > trying to get the contents of the Resource table to appear on my > form. I have then created a DataAdapter (tested the connection, set > the SQL as a simple SELECT * from Resource, etc), which also generates > an sqlConnection for me. To test this I have previewed the generated > data, and it returns what I want, so I > have chosen to generate a DataSet of this (dsResource). I am then > trying to get > this data into a simple DataGrid. On the properties of the DataGrid > I have changed the DataSource to point at my Dataset. As I > understand it, I then have to add the following to my Page Load > section of my code. > > sqlConnection1.Open(); > this.sqlDataAdapter1.Fill(this.dsResource); > sqlConnection1.Close(); > > The form builds fine, but when I browse to the particular form I get > the following error for the sqlConnection1.Open(); line > > Exception Details: System.Data.SqlClient.SqlException: Cannot open > database requested in login 'SCMS'. Login fails. Login failed for > user 'AL-NOTEPAD\ASPNET'. > > To me this is an error with my connection string. My database > instance is actually 'AL-NOTEPAD\VSDOTNET'. However the properties > for sqlConnection1 are pointing to the correct datasource. I do not > know why the application is looking for user 'AL-NOTEPAD\ASPNET'. It > does not exist, to my knowledge. > > Any help with this would be greatly appreciated, as I get the same > error with my code for forms-based login... > > > Thanks in advance.. > > hello thebison,
it seems to me that you are experiencing problem with the database permissions you have on your sql server. This happens because ASPNET, which is the default user account for your ASP.NET application, donot have access permission to the database you are using. If you have Enterprise Manager installed on your machine, you must assign access permission to ASPNET account. Under Security folder, Select New Login, browser for ASPNET account. Assign the database VSDOTNET to ASPNET account. b regards rodel e. dagumampan filipino c#/.net developer http://community.devpinoy.org/blogs/dehranph Hi everyone,
Thanks for all the help, I've sorted the problem in the short term by downloading an MSDE alternative to Enterprise Manager (http://www.asql.biz/DbaMgr.shtm) and assigned the relevant access to the ASPNET user account. The DataGrid now works. Thanks again Al great!
also, SQL 2005 Express is a full featured and worth looking into. Its free and support larger space. b regards rodel e. dagumampan filipino c#/.net developer http://community.devpinoy.org/blogs/dehranph |
|||||||||||||||||||||||