Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Getting dataset?

Reply
Thread Tools

Getting dataset?

 
 
Betina Andersen
Guest
Posts: n/a
 
      12-01-2006
I have a componentOne grid along with an SqlDataSource on my aspx page, now
I want to add a new row to my grid and tries to do this:

Dim ds As DataSet = Page.Session("MyDataset")
Dim dt As New DataTable
Dim dr As DataRow
dr = dt.NewRow()
dr.ItemArray = dt.Rows(0).ItemArray
dr.Item("Fag") = System.DBNull.Value
dr.Item("Tekst") = System.DBNull.Value
dt.Rows.Add(dr)
dt.AcceptChanges()
wgFag.DataSource = dt
wgFag.DataBind()

But I get an error in this line
dr = dt.NewRow()

and when looking my ds is Nothing - so how do I get the dataset from my
datasource into my ds variable?

Thanks
Betina


 
Reply With Quote
 
 
 
 
Masudur
Guest
Posts: n/a
 
      12-01-2006
Hi,

You might be getting a error like
" There is no row at position 0."
cause i dont see any code where you actually
refer your dt to any datatable of the data set.

more over sinse you are getting ds nothing. check your code where you
assigned the data set to session

Thanks
Masudur
Kaz Software Ltd.
www.kaz.com.bd

 
Reply With Quote
 
 
 
 
Betina Andersen
Guest
Posts: n/a
 
      12-01-2006
"Masudur" <(E-Mail Removed)> skrev i en meddelelse
news:(E-Mail Removed) ps.com...
> Hi,
>
> more over sinse you are getting ds nothing. check your code where you
> assigned the data set to session
>

The data comes from a datasource on the aspx page, it is created visually
and I can see the data in my grid - the above code is for a button I press
to get a new row, so I know I have data in my data source - and it is set to
a DataSet.

Regards Betina


 
Reply With Quote
 
Subbu
Guest
Posts: n/a
 
      12-01-2006
Dim dt As New DataTable
it gives error because the dt does not the strucutre of the table ,
that is it does not have the Column names init.
use this i think it will work dt = ds.Tables(0).Copy

Thank You
Subbu


Betina Andersen wrote:
> I have a componentOne grid along with an SqlDataSource on my aspx page, now
> I want to add a new row to my grid and tries to do this:
>
> Dim ds As DataSet = Page.Session("MyDataset")
> Dim dt As New DataTable
> Dim dr As DataRow
> dr = dt.NewRow()
> dr.ItemArray = dt.Rows(0).ItemArray
> dr.Item("Fag") = System.DBNull.Value
> dr.Item("Tekst") = System.DBNull.Value
> dt.Rows.Add(dr)
> dt.AcceptChanges()
> wgFag.DataSource = dt
> wgFag.DataBind()
>
> But I get an error in this line
> dr = dt.NewRow()
>
> and when looking my ds is Nothing - so how do I get the dataset from my
> datasource into my ds variable?
>
> Thanks
> Betina


 
Reply With Quote
 
Betina Andersen
Guest
Posts: n/a
 
      12-01-2006
"Subbu" <(E-Mail Removed)> skrev i en meddelelse
news:(E-Mail Removed) ups.com...
> Dim dt As New DataTable
> it gives error because the dt does not the strucutre of the table ,
> that is it does not have the Column names init.
> use this i think it will work dt = ds.Tables(0).Copy
>

Sorry but it does not work - my ds keeps being Nothing so there is nothing
to copy from, so I need to find out hw to get my data from my ds control
into my Dim ds variable.

Regards
Betina


 
Reply With Quote
 
Masudur
Guest
Posts: n/a
 
      12-01-2006

Betina Andersen wrote:
> "Subbu" <(E-Mail Removed)> skrev i en meddelelse
> news:(E-Mail Removed) ups.com...
> > Dim dt As New DataTable
> > it gives error because the dt does not the strucutre of the table ,
> > that is it does not have the Column names init.
> > use this i think it will work dt = ds.Tables(0).Copy
> >

> Sorry but it does not work - my ds keeps being Nothing so there is nothing
> to copy from, so I need to find out hw to get my data from my ds control
> into my Dim ds variable.
>
> Regards
> Betina


Hi,

I assume you are using sqldatasource to connect to the database. and
you are not using any typed dataset....
did you actually put your dataset in the session?

using sqldatasource direcly dont put your result set to session.

Thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
You Mean I Won't Be GEtting Paid More for Getting This Cert? TBone MCSE 13 10-30-2007 01:10 PM
You Mean I Won't Be GEtting Paid More for Getting This Cert? TBone MCDST 7 10-30-2007 01:10 PM
Re: You Mean I Won't Be GEtting Paid More for Getting This Cert? FrisbeeŽ MCSE 0 10-22-2007 03:32 PM
Getting User Input after getting Input from a file dei3cmix@uga.edu C++ 3 03-23-2006 05:01 AM
How to avoid getting BGP routes while getting a router's routing table ncosta@net.ipl.pt Cisco 2 01-25-2006 11:50 AM



Advertisments