Search Records in DataSet .
Search Records in DataSet .
using System;
using System.Data;
using System.Data.SqlClient;
class Check
{
SqlConnection con;
SqlDataAdapter adap;
DataSet ds;
public Check()
{
con=new SqlConnection("initial Catalog=PraticeCAC;data Source=OM-PC;integrated security=yes");
ds=new DataSet();
}
public void show_Recordcount()
{
adap=new SqlDataAdapter("Select *from tbl_studentRecords",con);
adap.Fill(ds,"student");
int t=ds.Tables["student"].Rows.Count;// this code for count the row or records in table
for(int i=0;i<t; i++)// this code for show data records in table .
{
Console.WriteLine(ds.Tables["student"].Rows[i]["rollno"]+""+ds.Tables["student"].Rows[i]["stud_name"]);
}
Console.WriteLine(t);
}
public static void Main()
{
Check c=new Check();
c.show_Recordcount();
}
}
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home