Interview Questions

How do you get records number from 5 to 15 in a dataset of 100 records? Write code.

.NET Database ,COM interop,and .NET deployment questions and answers


(Continued from previous question...)

How do you get records number from 5 to 15 in a dataset of 100 records? Write code.

Answer1
DataSet ds1=new DataSet(); String strCon=”data source=IBM-6BC8A0DACEF;initial catalog=pubs;integrated security=SSPI;persist” +” security info=False;user
id=sa;workstation id=IBM-6BC8A0DACEF;packet size=4096?;

String strCom1=”SELECT * FROM employee”;
SqlDataAdapter sqlDa1=new SqlDataAdapter(strCom1,strCon);
ds1.Tables.Add(”employee”);
sqlDa1.Fill(ds1,40,50,ds1.Tables[”employee”].TableName);
DataGrid dg1.DataSource=ds1.Tables[”employee”].DefaultView;
dg1.DataBind();


Answer2
OleDbConnection1.Open()
OleDbDataAdapter1.Fill(DataSet21, 5, 15, “tab”)
This will fill the dataset with the records starting at 5 to 15

(Continued on next question...)

Other Interview Questions