PC Review


Reply
Thread Tools Rate Thread

DataGrid - Dataset

 
 
Paul W Smith
Guest
Posts: n/a
 
      11th Oct 2007
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?


 
Reply With Quote
 
 
 
 
sloan
Guest
Posts: n/a
 
      11th Oct 2007


GridView1.DataSource = MyDataSet.Tables[0];


A DataSet is a collection of DataTables.

You have to pick a Table.




"Paul W Smith" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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?
>



 
Reply With Quote
 
IfThenElse
Guest
Posts: n/a
 
      11th Oct 2007
Where is the command object.

"Paul W Smith" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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?
>



 
Reply With Quote
 
IfThenElse
Guest
Posts: n/a
 
      11th Oct 2007
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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?
>



 
Reply With Quote
 
IfThenElse
Guest
Posts: n/a
 
      11th Oct 2007
good catch, I did not see this one.


"sloan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
>
> GridView1.DataSource = MyDataSet.Tables[0];
>
>
> A DataSet is a collection of DataTables.
>
> You have to pick a Table.
>
>
>
>
> "Paul W Smith" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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?
>>

>
>



 
Reply With Quote
 
sloan
Guest
Posts: n/a
 
      11th Oct 2007

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.




"sloan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
>
> GridView1.DataSource = MyDataSet.Tables[0];
>
>
> A DataSet is a collection of DataTables.
>
> You have to pick a Table.
>
>
>
>
> "Paul W Smith" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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?
>>

>
>



 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      11th Oct 2007
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?
>
>
>

 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      11th Oct 2007
"sloan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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


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

 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      11th Oct 2007
"Paul W Smith" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...

> 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

 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      11th Oct 2007
"IfThenElse" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

>> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: DataGrid and Dataset Usarian Skiff Microsoft VB .NET 0 19th Sep 2005 02:02 PM
Getting dataset row from datagrid Ron L Microsoft Dot NET Framework Forms 2 28th Oct 2004 06:32 PM
Re: datagrid without dataset Scott Microsoft ADO .NET 0 27th Jul 2004 07:37 PM
DataGrid Component | Displaying columns of a DataSet as Rows in a DataGrid ? Diego TERCERO Microsoft C# .NET 3 19th Dec 2003 02:21 PM
Re: Dataset and DataGrid Marc Scheuner [MVP ADSI] Microsoft ADO .NET 0 14th Aug 2003 08:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:00 AM.