473,324 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

DataGrid - Dataset

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?
Oct 11 '07 #1
10 1304


GridView1.DataSource = MyDataSet.Tables[0];
A DataSet is a collection of DataTables.

You have to pick a Table.


"Paul W Smith" <pw*@NOSPAM.twelve.me.ukwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
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?

Oct 11 '07 #2
Where is the command object.

"Paul W Smith" <pw*@NOSPAM.twelve.me.ukwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
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?

Oct 11 '07 #3
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...
"Paul W Smith" <pw*@NOSPAM.twelve.me.ukwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
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?

Oct 11 '07 #4
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

"Paul W Smith" wrote:
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?
Oct 11 '07 #5
"IfThenElse" <sq**********@hotmail.comwrote in message
news:O2**************@TK2MSFTNGP02.phx.gbl...
>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...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 11 '07 #6
"Paul W Smith" <pw*@NOSPAM.twelve.me.ukwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
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...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 11 '07 #7
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

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yohohhoandabottleofrum.comwrote
in message news:6C**********************************@microsof t.com...
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

"Paul W Smith" wrote:
>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?

Oct 11 '07 #8
Another way to help (future readers) is to post:
if you resolved the issue, and
what the resolution was.

...


"Paul W Smith" <pw*@NOSPAM.twelve.me.ukwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yohohhoandabottleofrum.com>
wrote in message
news:6C**********************************@microsof t.com...
>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

"Paul W Smith" wrote:
>>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?


Oct 11 '07 #9
PWS
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.

Oct 12 '07 #10
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.ManageUs ers"

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.


"PWS" <pw*@twelve.me.ukwrote in message
news:11**********************@y27g2000pre.googlegr oups.com...
>
>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.

Oct 12 '07 #11

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

Similar topics

0
by: Frosty | last post by:
Hi I am using the VS xsd designer to create a strongly typed dataset. The dataset is apparently successfully created, with no warnings or errors given. Is it not then to be expected that this...
0
by: Morné | last post by:
Hi how do I validate a text value in a datagrid e.g. the user is only allowed to type in a Y or a N. I specifically have a problem with using the PropertyDescriptorCollection. I get the...
1
by: Soul | last post by:
Hi, I have a DataGrid which works. But if I load a new table to the DataGrid, it will still show those old data I load earlier. private void loadTableA() { if ( openFileDialog.ShowDialog()...
3
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
4
by: Rod | last post by:
I posted a message to this group yesterday asking how to pass parameters to a web form that is the source of an IFrame on a parent web form. I've gotten my answer, and it works. Thanks! Now I...
3
by: CVerma | last post by:
Hi, I have an embedded datagrid within a datalist. I am not able to perfrom paging in the datagrid. Any ideas? Here is my code: Here is my Simplegrid.cs file: using System; using...
3
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...
17
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...
8
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.