Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how to connect asp.net appln from sql server 2005...and how to display the records...please help me..
Posted
Updated 18-May-11 22:15pm
v2

Read about ADO.NET here and it will help you.

Look at these:
MSDN: ADO.NET[^]
MSDN: Accessing Data with ADO.NET[^]
The C# Station ADO.NET Tutorial[^]
Using ADO.NET for beginners[^]
 
Share this answer
 
You can refer the following 2 links to get your job done:

1. http://msdn.microsoft.com/en-us/library/ff648340.aspx[^]
this will help in connection, its easy and clear.

2. http://msdn.microsoft.com/en-us/library/6759sth4%28v=vs.71%29.aspx[^]

this one is for displaying or accessing records
 
Share this answer
 
 
Share this answer
 
If you want to display records from database means you have to use some grids and want to open connection
sqlconnection con=new sqlconnection("Data Source=aa;UID=dd;password=ee;database=xx");
con.open();

con.close();
 
Share this answer
 
v2
<connectionStrings>

<add name="Personal" connectionString=" Server=whsql-v04.prod.mesa1.secureserver.net; Database=DB_675; User ID=user_id; Password=password; Trusted_Connection=False" providerName="System.Data.SqlClient" /> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString=" Server=whsql-v04.prod.mesa1.secureserver.net; Database=DB_675; User ID=user_id; Password=password; Trusted_Connection=False" providerName="System.Data.SqlClient" />

</connectionStrings>
 
Share this answer
 
v2
To connect to SQL Server from C#.NET, you need to create a connection string such as below:

private SqlConnection connection;
private string connectionString =
@"Server=(local);Database=Embedding_SQL_Test;User ID=sa;Password=123";
connection = new SqlConnection( connectionString );

Next, you use the SqlConnection object created above to create a 'SqlCommand', as shown below:
SqlCommand cmd = new SqlCommand( "select * from Customer where CustomerID = @Cid", connection);

The SQL query shown here can be replaced by a SELECT, INSERT, UPDATE queries etc.

Next to execute the SQL queries in the database, you use the following methods:
ExecuteReader - to execute SELECT queries
ExecuteNonQuery - to execute INSERT, DELETE, UPDATE, and SET statements.

This is a very short description of how to connect to SQL Server database from C# and execute SQL queries in the database.
For details about the connection string, the methods and their parameters check the following link: ( http://www.shahriarnk.com/Shahriar-N-K-Research-Embedding-SQL-in-C-Sharp-Java.html )
Here you will also find details about how to pass parameters to the SQL queries as well as calling stored procedures and much more.
 
Share this answer
 
v2
Comments
mohd ouais 7-Apr-13 13:42pm    
condition in sql
mohd ouais 7-Apr-13 13:44pm    
condition in sql codding
By searching google or any search engine site.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900