473,769 Members | 3,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with ASP.NET DataGrid problem

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. 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.sqlDataAda pter1.Fill(this .dsResource);
DataGrid1.DataB ind();
sqlConnection1. Close();

The form builds fine, but when I browse to the particular form I get
the following error for the sqlConnection1. Open(); line. If I remove
this line the error simply moves to the line below.

Exception Details: System.Data.Sql Client.SqlExcep tion: 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\VSDOTNE T'. 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. Do I need to grant access to this
user? If so, how would I do it?

Any help with this would be greatly appreciated, as I get the same
error with my code for forms-based login...
Thanks in advance..

Feb 4 '06 #1
2 1179
> Exception Details: System.Data.Sql Client.SqlExcep tion: 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\VSDOTNE T'. 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. Do I need to grant access to this
user? If so, how would I do it?

The ASPNET user is a local user created when you installed VS. By default
the web apps are using this as the logon user for browser sessions.

I'm not entirely sure why your integrated (SSPI) setting is being ignored.

You can override this for your data connection by editing the connection
string to include a SQL user. This user needs to have sproc execute
permissions, which you can set in SQL Enterprise Manager. You may want to
consider adding a Role, setting the sproc exec permissions for the role,
then having the SQL user account be a member of the role.

It may also be useful to know that the connection string can be stored in
your web.config, using a custom configuration key. This would prevent you
having to recompile the app if the SQL user account password ever changes.
If necessary, you can hash the connection string to make it more secure.

sqlConnection1. Open();
this.sqlDataAda pter1.Fill(this .dsResource);
DataGrid1.DataB ind();
sqlConnection1. Close();


You may want to add
DataGrid1.Datas ource = sqlDataAdapter1
before your bind statement if you haven't already done this using the
designer properties.

Hope this helps.

Al
Feb 4 '06 #2
Hi,
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

Alex

Feb 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3131
by: pei_world | last post by:
Hi, there; I have a problem with my datagrid control. I declared it in one of my form, set with DataGridTalbeStyle as well, and when I click on button, I would like to retrive Data from Database and bind these data to my datagrid in the form, when I click the button first time, it work fine. but when I click the second button. it report belowing error, I guess it is because it already set up the column name at first time, so cann't do...
0
3645
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a datagrid on the left side that lists names and perhaps a couple of other key fields. The user can click on a record in the datagrid, which should automatically pull up details on that record in the various text boxes and other controls on the right...
1
1331
by: Maqsood Ahmed | last post by:
Hello! There is a DataGrid on a form that is populated through DataTable and filters have been applied to through DataView. The DataTable gets updated through some events and obviously it also reflects at the datagrid. Now problem arises, that whenever a new record is being inserted in the datagrid, It scrolls waywardly, that distracts the user's view. Is there any solution that this should not happen. Points to note: - DataGrid is not...
1
1722
by: Mike Speak | last post by:
On my page_load, I am populating a Datagrid through the normal manner (which works) before attempting to pick out the items in one column to use in another part of my page. This is all within page_load. Within my Datagrid I have an <ItemTemplate/> tag with a child <asp:Label/> tag. The ID on the <asp:Label/> tag is set to "lblDescription". I am using the following code to iterate over the DataGrid control and pick out the descriptions...
7
15442
by: Juan Romero | last post by:
Hey guys, please HELP I am going nuts with the datagrid control. I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output the file to a folder, and then I read it back into the dataset using the dataset1.readxml. Up to this point, everything works wonderfully. The query executes, the dataset gets populated, and I get the results displayed in the datagrid.
14
1840
by: Brett Sinclair | last post by:
Hello everybody I'm still on the learning curve here...and from what I read, I created inherited datagrid class so I could have icons, combobox...etc in the columns of my datagrid. The grid will be used to populate information coming from a Webservice. (No datasets - No datareaders). So, I do not know see how to use the "datasource".
3
2521
by: Datatable Dataset Datagrid help | last post by:
Hi I am somewhat confused, I am new at VB.net I use XML data, I have a datagrid, I created a datatable so that I can create a custom format like true is this graphic false is this graphic and others. One of the custom format is as follows: dsmessages_dt.Columns.Add("Image", GetType(Image)) I had a problem of when I used a checkbox in the grid that was bound to the datatable that it would not update my dataset. So I created another...
17
2770
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only allow user to filter the first time, when they tried the second time, the speficied cast error message will prompt one.... I create a mydataset1 first, and the mydataset1 data source was getting from DataGrid.DataSource.
4
2138
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a Delete button on the end of each row. I am unable to gain access to the event when the button is clicked. I don't fully understand how the click gets connected to the C# code,
2
1449
by: settyv | last post by:
Hi, I have webform which has 4 Datagrid controls with (built-in Pagination) and 4 search buttons to perform the search operation.When i click on search operation it is displaying the results in grid .when i click next it is telling error...Please let me know how to solve this problem. Below method can be used for all the datagrids.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9996
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3963
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.