473,396 Members | 1,871 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,396 software developers and data experts.

Getting dataset?

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
Dec 1 '06 #1
5 1055
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

Dec 1 '06 #2
"Masudur" <mu*****@gmail.comskrev i en meddelelse
news:11*********************@73g2000cwn.googlegrou 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
Dec 1 '06 #3
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
Dec 1 '06 #4
"Subbu" <ve*******@gmail.comskrev i en meddelelse
news:11**********************@80g2000cwy.googlegro 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
Dec 1 '06 #5

Betina Andersen wrote:
"Subbu" <ve*******@gmail.comskrev i en meddelelse
news:11**********************@80g2000cwy.googlegro 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

Dec 1 '06 #6

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

Similar topics

1
by: Oleg Shnayderman | last post by:
Hi All, I am very new to C# as well as to SQL. I need to write an application which is connecting to SQL DB and getting all the user's tables and after create a dataset for all the tables in the...
6
by: Erik H. | last post by:
Trying to connect to MySQL db on localhost, and populate datagrid from a dataset using code inline method. Getting the following compile error: Error Message: "CS0246: The type or namespace...
4
by: What-a-Tool | last post by:
I am trying to write a program that will take all the members of a data base, add them to a tree, with all child relations as sub-nodes. I am having a problem getting the parent child relations...
4
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Why am I getting an error when I passed by ref a dataset to a new form? The message reads "cannot convert from 'ref Paimport.unixAccount' to 'ref System.Data.DataSet'. Paimport is the name of the...
2
by: rocketfire97 | last post by:
I'm trying to call a COM object using C# but having no luck getting values back for passed in ref objects. I've tried the same call using VB.NET and can get data back. How would I implement the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.