Answer Posted / venky
Dear friend my answer is relating to csharp.net....SQLSERVER Database.
TO get records from database
1) our Application have to Connect with database.
SQlconnection cn=new sqlconnectio(@"server=.\SQLEXPRESS;Database=mydatabase;Integrated Security=SSPI");
cn.open();
2) we have to prepare COMMAND object Which encapsulate a sql statement and connection obj.
SQLCommand cmd=new Sqlcommand("select * from table1",cn);
then we call following method to get records
SqlDataReader rdr= cmd.ExecuteReader(CommandBehavior.CloseConnection);
int f_cnt= rdr.FieldCount;
Type t= rdr.GetFieldType(1);
while(rdr.Read())
{
int cou = rdr.FieldCount;
for(int i1=0;i1<cou;i1++)
{
string s2 = rdr.GetValue(i1).ToString();
ans = ans + " " + s2+" ";
}
i++;
ans = ans + "\n";
}
MessageBox.Show(ans);
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How do you apply specific formatting to the data inside the cells?
What is form and meaning?
What is the difference between pixels, points, and em’s when fonts are displayed?
Where to use new keyword other than create instance?
How do I change the console application in windows?
Is windows an application software?
What is the use of form?
Name the property which of menu cannot be set at run time?
Explain how barcode create in the report?
how print PGL by XML
Explain the difference between listbox and combo box?
Name the method that has to be overridden to change the appearance of the control that is inherited from an existing control.
What is a windows form application?
What is form description?
What is the difference between desktop application and windows application?