Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
[connection object creation]
Dim sSQL As String = "SELECT * FROM tPlayers"
Dim myAdapter As OleDbDataAdapter = New
OleDbDataAdapter(sSQL,myConnection)
Dim MyDataSet As New DataSet
myAdapter.Fill(MyDataSet)
GridView1.DataSource = MyDataSet
GridView1.DataBind()
myConnection.Close()
End Sub
I know the connection object is good because I use it else where, I have
edited out from the event above.
I have the require Namespaces , so it must be syntax, but I cannot for the
life of me see what the problem is.
Can anyone else?
sloan - 11 Oct 2007 20:51 GMT
GridView1.DataSource = MyDataSet.Tables[0];
A DataSet is a collection of DataTables.
You have to pick a Table.
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs)
[quoted text clipped - 25 lines]
>
> Can anyone else?
IfThenElse - 11 Oct 2007 20:56 GMT
good catch, I did not see this one.
> GridView1.DataSource = MyDataSet.Tables[0];
>
[quoted text clipped - 31 lines]
>>
>> Can anyone else?
Mark Rae [MVP] - 11 Oct 2007 21:03 GMT
>> A DataSet is a collection of DataTables.
>>
>> You have to pick a Table.
> good catch, I did not see this one.
Makes no difference if the DataSet has only one Table...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
sloan - 11 Oct 2007 20:57 GMT
You can also do this as a DEBUG technique.
string x = MyDataSet.GetXml();
or (vb.net)
dim x as string = MyDataSet.GetXml()
..
Look at the x value, and make sure you have information in there.
> GridView1.DataSource = MyDataSet.Tables[0];
>
[quoted text clipped - 31 lines]
>>
>> Can anyone else?
Mark Rae [MVP] - 11 Oct 2007 21:00 GMT
> GridView1.DataSource = MyDataSet.Tables[0];
>
> A DataSet is a collection of DataTables.
Yes it is.
> You have to pick a Table.
No you don't - if the DataSet has only one table, you don't need to specify
it...
GridView1.DataSource = MyDataSet

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
sloan - 12 Oct 2007 15:49 GMT
Ahh. You got me Mark, well played.
Now I remember that code which checks the "object" datasource, and you're
right, there is a
"If type is dataset and table.count = 1 then use the first table
(table[0])."
So I was off on this one, however it is good to know that if you have a
DataSet with more than 1 table, you need to specify the specific table of
interest.
>> GridView1.DataSource = MyDataSet.Tables[0];
>>
[quoted text clipped - 8 lines]
>
> GridView1.DataSource = MyDataSet
IfThenElse - 11 Oct 2007 20:51 GMT
Where is the command object.
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs)
[quoted text clipped - 25 lines]
>
> Can anyone else?
IfThenElse - 11 Oct 2007 20:55 GMT
Never mind command object,
Are you or are you not getting a Syntax error.
Syntax errors are generated by the complier before the runtime errors.
Can you findout what you get from MyDataSet.Tables.count?
or MyDataSet.Tables[0].Rows[0].count
etc...
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs)
[quoted text clipped - 25 lines]
>
> Can anyone else?
Peter Bromberg [C# MVP] - 11 Oct 2007 20:58 GMT
Paul,
If it isn't working that means your code is likely throwing an exception.
But - you don't have it wired up to catch exceptions. Wrap the whole thing
in a try / catch block and in the catch block you can output the exception's
Message and StackTrace properties to the debug window and even set a
breakpoint on the debug.WriteLine statement and mouse over the exception
object to examine it with Text Visualizer from Intellisense. That's faster
than asking questions on newsgroups and waiting around for answers!
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
>
[quoted text clipped - 24 lines]
>
> Can anyone else?
Paul W Smith - 11 Oct 2007 22:32 GMT
Wow....... I fell like I am being told off by the teacher for not knowing
something.
Do you have to be an expert to use this forum or can beginners use it as
well!!!
I do appreciate your initial comments, as I have all the ones that have been
made, why you felt the need to advise me that 'knowing' what to do is faster
than asking seems strange to me.
Again thanks to everyone who took time to offer some advise - which I always
thought was the purpose of these forums.
PWS
> Paul,
> If it isn't working that means your code is likely throwing an exception.
[quoted text clipped - 41 lines]
>>
>> Can anyone else?
sloan - 11 Oct 2007 23:26 GMT
Another way to help (future readers) is to post:
if you resolved the issue, and
what the resolution was.
..
> Wow....... I fell like I am being told off by the teacher for not knowing
> something.
[quoted text clipped - 58 lines]
>>>
>>> Can anyone else?
PWS - 12 Oct 2007 09:45 GMT
> Another way to help (future readers) is to post:
> if you resolved the issue, and > what the resolution was.
I always like to try to help others where I can.
I have solved my problem, but I still do not understand it so perhaps
someone might assist me.
I am a little loathed to write this because it probably shows both my
inexperience and lack of knowledge, you can only get so much from
reading books, and I am not a ASP.NET professional, just a keen
amateur who codes in his spare time on small projects.
My problem which I discovered by trying to debug my code was that it
was not running. I am using Visual Studio 2005 and I noticed that
when in Source View "Client Objects and Events" was displayed, rather
than "Server Objects and Events." Unfortunately I looked in the drop
down and did not see "Server Objects and Events" so just opened a page
that did work and saved it with the new required name and amended the
code.
Thanks to everyone who tried to assist, your advice was apprecaited
and follwoing it helped me find my problem.
sloan - 12 Oct 2007 15:44 GMT
That's cool dude.
Live and learn with this stuff.
I'm a little unsure about what you've said, but I'll take a guess.
Look at the code of the aspx page (the html-ish type stuff, not the code
behind page).
CodeBehind="ManageUsers.aspx.vb"
Inherits="MyApplication.Presentation.Web1.ManageUsers"
When you do "copy and paste" stuff, sometimes this things get out of whack.
I'm probably way off, but thought I'd mention that one, since I was burned
by it early on.
>> Another way to help (future readers) is to post:
>> if you resolved the issue, and > what the resolution was.
[quoted text clipped - 19 lines]
> Thanks to everyone who tried to assist, your advice was apprecaited
> and follwoing it helped me find my problem.
Mark Rae [MVP] - 11 Oct 2007 21:01 GMT
> I have the require Namespaces , so it must be syntax, but I cannot for the
> life of me see what the problem is.
>
> Can anyone else?
You've forgotten the Command object...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net