Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want use "disconnected model" to access database. Dataprovider which I am using is "OLEDB", I have a database to manage students in a school, I want get students in a class but i can't. After accessing database, the thing I received is a table which involved all of the students in the school. When I used "connection model" to access database. I can do get students in a class by using "@SelectedClass" parameter. May you help me ???
Posted
Comments
kid218 15-Oct-10 5:32am    
myConnect.open();
string myStringCommand = "SELECT ordinal, codeOfStu, fullName, ST.codeOfClass, CL.nameOfClass FROM Student ST, Class CL WHERE ST.codeOfClass = CL.codeOfClass AND ST.codeOfClass = @SelectedCodeOfClass";
OleDbCommand command = new OleDbCommand(myStringCommand, myConnect);
OleDbParameter myParameter = new OleDbParameter("@SelectedCodeOfClass", OleDbType.Integer);
myParameter.Value = SelectedCodeOfClass; // SelectedCodeOfClass is a parameter which is carried from main function.
myCommand.Parameters.Add(myParameter);
OleDbDataReader myReader = myCommand.ExecuteReader();
.
.
.

Now, I want not use "connect model" to access database anymore. I want use "disconnect model" to do that.
If I do like this:
OleDbDataAdapter adap=new OleDbDataAdapter("select * from tablename",con);
Dataset ds=new Dataset();
adap.fill(ds);

The Thing I receive is a datatable involve in all of the students. I don't want read all of the Student 's Information in database. I only want read students' Information according to class (codeOfClass) that they belong to

Are you getting an error?
If so what?

You need to provide more information before someone can help you.
 
Share this answer
 
Please clarify your question a bit more about the table and how u r using in ur code.
or U can use as
OleDbDataAdapter adap=new OleDbDataAdapter("select * from tablename",con);
Dataset ds=new Dataset();
adap.fill(ds);
Gridview1.DataSource=ds;
Gridview1.DataBind();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900