guys . please help me how to connect a database in c#. thanks .

SQL Server, or something else? Look up the C# documentation for ODBC.

you can simply do this

//import the sqlclient library at the top like this
using System.Data.SqlClient;

'now you can connect to your database like this 
SqlConnection con = new SqlConnection(|"Data Source=YourServerAddress;Initial Catalog=YourDatabaseName;Integrated Security=SSPI;");
con.Open();
//here you can perform any database  operation using different objects like
//sqldataadapter
//sqldatareader
//sqlcommand
con.Close();

every time you want to perform any database operation you have to open and then close the connection.

Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.