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
Is typeform free?
Which template creates a .net compact framework 2.0 forms application for pocket pc 2003 and later?
What are controls in windows forms?
Explain how insert record in the database?
How do I change the console application in windows?
Which command prompt utility is used to convert a resource file from the text format into the binary format?
How to create a set up in vb.net for desktop application please say steps with examples?
What is form based application?
What is form technology?
What is the synonym of form?
What are the forms of database?
Name the event that enables the user to prevent shifting of focus from control until all the validation rules have been met.
Which window allows viewing the resources of the servers, such as services, processes and the event log?
How do you apply specific formatting to the data inside the cells?
Which property of the errorprovider control automatically sets to the form to which?