Hoe can i connect the table into the c# application?

Answer Posted / umesh shrivastava

if we are using web application
1-open web.config file
<ConnectionString>
<add name="connect" connectionstring="Data Source=
,IntialCatalog= " Username= ,Password=
;providerName="System.Data.SqlClient"
</ConnectionString>
2-write namespace at the top in .cs file System.Data.SqlClient;
2-now write this code to button click event
String
ss=ConfigurationManager.ConnectionString["connect"].ConnectionString;
Sqlconnection con=new SqlConnection(ss);
con.open();
SqlCommand cmd=new SqlCommand("select * from emp",con);
SqlDataReader r=cmd.ExecuteReader();
con.close();

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define a class and an object?

551


What are the different types of constructors in c#?

499


If you define a user defined data type by using the class keyword, is it a value type or reference type?

486


Wcf and what is difference between wcf and web services?

481


What is the difference between static and constant variables?

535






Why do we need interfaces in c#?

477


Explain the process of Serialization?

542


What is a sealed class?

506


What is the use of ienumerable?

450


What is the full form of GAC? Explain its uses?

572


What is the wildcard character in sql?

516


What is the difference between interface and abstract class in c#?

456


Explain about Error handling and how this is done

528


In which way a two-dimensional array declared in C#?

498


Which class comes after the SortedList class?

559