DML operation on Dataset

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2009
Posts: 2
Reputation: mr.mukesh is an unknown quantity at this point 
Solved Threads: 0
mr.mukesh mr.mukesh is offline Offline
Newbie Poster

Re: DML operation on Dataset

 
0
  #11
Jan 9th, 2009
Iterating through the DataSet:

Here is a simple code to iterate through the dataset and select individual items instead of selecting all the data in the DataSet.

SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROm Categories",myConnection);

DataSet ds = new DataSet();

ad.Fill(ds,"Categories");

DataTable dt = ds.Tables["Categories"];


Response.Write(dt.Rows[0][1].ToString()) ;

1) First few lines are identical which we have done before.

2) In the forth line we declared the DataTable object. DataTable object is used to hold a single table. As I already told you that dataset can hold multiple tables depending upon the query so we can assign a single table from the dataset to the datatable object. I have done that using the line.

DataTable dt = ds.Tables["Categories"];

3) Next we are printing the first row of the second column. Always remember that the number of the rows and columns in the database does not start with 1 but it starts at 0. So in this line of code:

Response.Write(dt.Rows[0][1].ToString()) ;

This line of code means that get Row '0' and Column 1 of the from the datatable. And so we get the value and it prints out "Beverages".

Saving dataSets in Session State:

DataSets can also be saved in the Session State so that it can be available in other areas of the application and in new pages. The way of storing the DataSet in Session State is very easy.

Session["MyDataSet"] = DataSet;

Later if you want to retrieve the DataSet from the Session State you can easily do this by using this line of code:

DataSet ds = (DataSet) Session["MyDataSet"]

As you can see that when I am retrieving the values from the Session object I am casting it into the dataset object. This is because this is explicit conversion and requires casting. I am unboxing in this case.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 56
Reputation: karthi_selva is an unknown quantity at this point 
Solved Threads: 0
karthi_selva karthi_selva is offline Offline
Junior Poster in Training

Re: DML operation on Dataset

 
0
  #12
Jan 30th, 2009
hi currently i m using.

connection=new oledbconnection(oracle connection);
connection.open();
command=new oledbcomman("select * from table_name");
adapter=new oledbdataadapter(command);
adapter.fill(dataset,"Tableinfo");


now i need to get the data from the dataset using only DML.

i tried the following coding but its not working.

conn= new oledbconnection("Provider=SQLOLEDB; server=(local);integrated security=SSPI; database=northwind");
conn.open(); // exception occur in this place.

command = new oledbcommand("Select column from Tableinfo", conn);
.......................

please give an idea i tried many times and still i m face the problem.........
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 56
Reputation: karthi_selva is an unknown quantity at this point 
Solved Threads: 0
karthi_selva karthi_selva is offline Offline
Junior Poster in Training

Re: DML operation on Dataset

 
0
  #13
Jan 30th, 2009
Originally Posted by LizR View Post
We will help you, but we wont write anything for you. google, has nearly all the answers you could need. Have a look.
hi currently i m using.

connection=new oledbconnection(oracle connection);
connection.open();
command=new oledbcomman("select * from table_name");
adapter=new oledbdataadapter(command);
adapter.fill(dataset,"Tableinfo");


now i need to get the data from the dataset using only DML.

i tried the following coding but its not working.

conn= new oledbconnection("Provider=SQLOLEDB; server=(local);integrated security=SSPI; database=northwind");
conn.open(); // exception occur in this place.

command = new oledbcommand("Select column from Tableinfo", conn);
.......................

please give an idea i tried many times and still i m face the problem.........
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 56
Reputation: karthi_selva is an unknown quantity at this point 
Solved Threads: 0
karthi_selva karthi_selva is offline Offline
Junior Poster in Training

Re: DML operation on Dataset

 
0
  #14
Feb 11th, 2009
The only easiest method is
LINQ
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC