Hi,
I have database connection problem.
A part of the source is shown Below
private void Form3_Load(object sender, EventArgs e)
{
string connectionstring="Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\hospdb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
SqlConnection con=new SqlConnection(connectionstring);
DataSet ds=new DataSet();
string command="SELECT Name,Address,Phone,Branch,Class FROM hosptab WHERE (Branch = 'SKIN')";
SqlDataAdapter da=new SqlDataAdapter(command,con);
da.Fill(ds,"hospital");
DataTable dt=ds.Tables["hospital"];
//da.Fill(hospdbDataSet, "hospital");
con.Open();
// TODO: This line of code loads data into the 'hospdbDataSet.hosptab' table. You can move, or remove it, as needed.
this.hosptabTableAdapter.Fill(this.hospdbDataSet.hosptab);
con.ResetStatistics();
con.Close();
con.Dispose();
}
The SQL query is not working.It is showing all the rows in the database.Please show me how to establish a connection with the database and also,how to execute that sql command which is to be shown in data grid view.Any help Please?:$
Any way thanks for Advance:)