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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid not showing...

Status
Not open for further replies.

Isadore

Technical User
Feb 3, 2002
2,167
US
I'm new at all this but have spent several hours going through many many examples of doing a simple hook up to a data grid in Studio.NET.

The grid never appears in browser mode; everything is perfectly set up; cnn, adapter, dataset, Grid parameters;

any ideas?
 
The most likely cause for this is that the grid is not being filled.
1. Check to make sure there is data in the database you are connecting to.
2. Ensure you are filling the grid in the page onload event
3. Ensure your dataset is being filled properly.
 
Zarcom:

Thanks for the response. The database is connected properly, and filled, as I can see it using the Service Explorer (when I click on one of the tables, it reveals the data), and secondly, when I preview the dataset, the data comes up with no trouble.

I had read that the "fill" code should be put in the "New" Sub (Constructor sub), which I created and placed it there, and also I placed the fill code in the Page_Load event, but when I do that, interestingly, I get an error that says "either the database is already open by another user, or you do not have permission to view data."

I have spent nearly all of today (8hrs) trying to get past this problem as I want to move on to the Command business and get an SQL underway...

Inasmuch as the data being filled "correctly" I am doing everything correct in Studio.NET (I have several books at hand)...hard to understand...Test Connection for dbase is fine, etc...
 
what fill code are you using I believe that the following is all that should be needed. Of course the datagrid's data source needs to be set as well.

If Not Page.IsPostBack Then
Me.DataGrid1.DataBind()
End If


The error that you speak of did you try this once or are you consistently getting the error?

You may have to grant database access to the IUSR account. Other than this I am not to sure...
sorry I couldn't help more
[peace]
 
Here's the code:

Private Sub Page_Load(ByVal sender As...
DataSet11.Clear()
OleDbDataAdapter1.Fill(DataSet11)
End Sub

I'll try your solution and get back with you..by the way, thanks Zarcom for the response...makes a big difference, esp on this project, as several hundred people are hoping I get a simple "data" entry form on the net for them before their annual picknic on June 6th.

I have to start by selecting a watershed (they are citizen water monitors) and then a Group and then a site, at which point they can then enter their data...

So...you help is greatly appreciated. I'll get back within the half hour...will try now...
 
from the looks of you code all you should need to add is the databind code

datagrid.datasource = dataset11
datagrid.datamember = nameofdatamemberhere
datagrid.databind()


hope this helps
have fun at your piknik
[peace]
 
Binder code is bringing up the "Column Titles" which are stretched vertically and occupy the entire grid space...will check out the ISUR accout...at least did not get the error of can't view database...but "fill" code taken out...thanks for your time Zarcom...when I get past this I'll repost and settle the issue best I can...
 
Zarcom: Have tried to going through the IUSR, etc etc and being as liberal as possible opening up permissions, etc... with no luck.

Perhaps this post will help others when they come along -- I have 12 hours of not being able to "bind" a grid -- so I will back up, re-read materials on installing IIS, etc etc... and see what I can dig up...

All combinations of code only lead to "...you do not have permission to view database."

So, must reside in a permission somewhere....
 
I think you may have misunderstood somewhat. You say that you took out the fill code? That does need to be included.

Isadore what database are you using? Is it Oracle, Access, SQL??
 
Zarcom: Yes, using Stuido, and the examples in the book, etc... some examples are not using the fill method - and I get the impression that the dataset added by Sutdio has the capacity to obtain from the adapter the nec. data without having to go through a Open conn, Close conn, routine...etc..

I have an Access Database.

I am going to reformt my hard drive, re-install IIS and Stuido.NET - my computer (Compaq Pres. 2700) is acting up a bit, and when I installed XP Professional, it didn't seem to go right (wiping all of my programs out in the process)-

At any rate this may not have anything to do with it -- but getting a "clean" start seems reasonable...
 
The open conn close conn doesn't nessecarily need to be there, but I am pretty sure that the fill method must be included. I could be wrong.

You've got me stumped I am not sure what it could be. Tell me if the format works.

Sorry I couldn't help
[peace]
 
Zarcom:

As soon as all is working I will post a "Note" outlining what is necessary, etc... so this post can drift away!

Thanks for all your help. I will be studying .NET for the next year so will try and get up to speed where I can help a few people here at Tek Tips.

We'll keep ya posted Zarc. Take care and thanks.

 
Just had a new thought. Can you open the database normally ie. double click. If you can does it ask for a username and password? If so those need to be included in the connection string. Are you making the connection using design time components or compile time?

One other thing I had thought of to check is the second part of your error message. 'Open by another user'
Check in the directory the database resides is there a file of the same name as the database with the extentsion .ldb. If there is someone either has the database open or it has not been closed properly. If your certain no one is working on it the delete the .ldb file.

hope this helps [peace]
 
Zarc: No password. Right now on day 3 trying to come to grips with this problem. I created a new workgroup and placed the "*.mdw" file in the all permissions with access are open, so far as I can tell.

Opened up a new database, imported one table, and then saved and renamed the mdb in the Test connection and all other indications within Studio suggest that all is ok; and, by the way, the code for filling a datagrid, best I can tell since I haven't accomplished it yet, is...

DataSet11.Clear()
DataAdapter.Fill(DataSet11)
GridData1.DataBind()

...the bind being needed in Web Forms, but not in Windows forms, the fill needed in both (something I have read).

...so I am stumped...can't figure out what the heck this is. I am on day 3 now, getting quickly behind on this and other projects as the error message is killing me.

...no doubt, when it's solved, we can post a new "bulb" message and possibly submit within the FAQ so no one else has to go through the problems I'm going through. In the end, who knows, might be something simple; but I have been reading and reading and reading and can't find a clue...still lots of research to do...

...also, in one of the example CDs I have they activate MSDE to run samples but I presume that is for the SQL Adapter samples only; I figure OLE DB doesn't rely on that.

...since last nite I was certain that this problem involved internal mdb permissions...but after trying several approaches no luck yet...
 
Zarc: Thanks for all your help. Just getting my feet wet so was pretty frustrated initially - determined that the problem was not "correctly" configuring the Front Page Extensions, once that was done right, the Grid showed up!

No surprise there.

And so I'm finally off and running; although I realize that working with OLE DB and Access I'm not exactly in the forefront of development. I am currently struggling with a DataGrid, getting it to behave so I can open up the next web page....

....Also, looking for a good "File Upload" page for stuffing images into an Access table...any ideas would appreciate!

Thanks Zarc. Appreciate your time.
 
I have not yet done anything with File Uploads in .NET. However, this is an area of interest to me since the project I am currently working on may incorporate putting images into a sql table.

Hey I am glad to help out I am new to .NET as well goin on 4 weeks of development now. [peace]
 
Isadore, can you elaborate on how you got the data grid to show up? I'm having the same problem right now.

Thanks.
 
RiverGuy: Its been a while since this thread was up. Must of had to do with binding the data, can't exactly remember.

I have plenty of example code now that works well. Let me know and I'll forward it to you. Seems early on in May when I was new to do NET I was running into a lot of small problems --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top