.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 29th, 2003, 05:40 AM
karthikmd karthikmd is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 karthikmd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question retrieving data from a dataset in ADO.net

i am basically trying to implement paging in a datagrid. instead of retrieving data from the database on every next click, i thought of putting it into a dataset and then querying it, so that it would be faster.

i have populated a dataset with data through a data adapter. i now need to access the data in the dataset and put it into a data adapter. after which i have to put this data into a datagrid.
i want to put this data into the data adapter through a Select statement as follows:

System.Data.DataColumn dc2 = this.myDataSet.Tables[0].Columns["Customerid"];

string selectQuery = "Select top ' "+pageSize+" ' * from "+this.myDataSet.Tables[0]+" where dc2 > '"+lastId+"'";

SqlDataAdapter myAdapter = new SqlDataAdapter(selectQuery,myConnection);

DataTable myTableTemp = new DataTable();
myAdapter.Fill(myTableTemp);
myDataGrid.DataSource = myTableTemp;

i get a dataprovider error when i use the Select statement.\

can anybody help me out. thanks in advance

Reply With Quote
  #2  
Old November 20th, 2003, 07:36 AM
Schnicka Schnicka is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Germany
Posts: 9 Schnicka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
well, i got the same source in a way- and it seems to work properly! but i recognized, that you donīt open a "SqlConnection"-Object. Try this:

Code:

SqlConnection dbConnection = new SqlConnection(myConnection);
dbConnection.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(selectQuery, myConnection);
dbAdapter.Fill(myTableTemp);
dbConnection.Close();


...and so on!

Please check also your ConnectionString - maybe you got an error in it!

Reply With Quote
  #3  
Old November 20th, 2003, 07:40 AM
Schnicka Schnicka is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Germany
Posts: 9 Schnicka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Iīve found another fault in your code at

Code:

string selectQuery = "Select top ' "+pageSize+" ' * from "+this.myDataSet.Tables[0]+" where dc2 > '"+lastId+"'";


it has to be like this:

Code:

string selectQuery = "Select top'"+pageSize+"'*
from "+this.myDataSet.Tables[0].ToString()+" where dc2 >'"+lastId"";

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > retrieving data from a dataset in ADO.net


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT