|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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! |
|
#3
|
|||
|
|||
|
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""; |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > retrieving data from a dataset in ADO.net |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|