Click here to Skip to main content
15,911,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi sir/mam,
How we work with sql dataadapter in a class in asp.net?i have work with datareader.but m not understand that how i work with dataadapter?

















Thank you.
Posted

You didn't specify what the actual problem is but have a look at the example in the documentation: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.aspx[^].

It shows how to use the adapter to fill a datatable.
 
Share this answer
 
Some subtle differences between the reader and adapter mentioned at http://www.bestdotnet.com/2007/11/dataadapter-vs-datareader.html[^],
 
Share this answer
 
Comments
SURBHI TYAGI 9-Apr-11 10:44am    
public class Class1
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}
public SqlDataReader getData()
{
SqlDataReader dr = null;
SqlCommand comm = new SqlCommand();
try
{
comm.CommandText = "select * from emp";
comm.CommandType = CommandType.Text;
comm.Connection = new SqlConnection("Data Source=DELL-PC;Initial Catalog=employeee;User ID=sa;Password=shristi");
comm.Connection.Open();
if (comm.Connection.State == ConnectionState.Open)
dr = comm.ExecuteReader();

}
catch (Exception exe)
{
throw;
}


return dr;
}
here i work with datareader.now i wana work with data adapter.then how will i do it?
this is in the class within appcode.plz give me any example.

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