Click here to Skip to main content
15,896,727 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i m new for win application,

i have no any idea to access centralize database in windows application

please help me .

here i have confuse to access one system data base use to other system by connected local server

please give any idea to connection-string or any other requirement to do this, step by step.
Posted
Comments
[no name] 26-May-14 9:33am    
www.connectionstrings.com

 
Share this answer
 
using System.Data.SqlClient;


private void button1_Click(object sender, EventArgs e)
{
    string connectionString = "Data Source=SERVERNAME;Initial Catalog=BASENAME;Persist Security Info=True;User ID=USERNAME;Password=PASSWORD";
    SqlConnection conn = new SqlConnection(connectionString);
    conn.Open();
    string cmdText = "select * from TBL1";
    SqlCommand cmd = new SqlCommand(cmdText, conn);
    SqlDataReader rdr = cmd.ExecuteReader();
    DataTable tbl = new DataTable();
    tbl.Load(rdr);
    dataGridView1.DataSource = tbl;
    conn.Close();
}
 
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