Add Namespace :
using System.Data.SqlClient;
Code:
SqlConnection con;
SqlCommand cmd ;
SqlDataAdapter adp = new SqlDataAdapter();
DataSet ds = new DataSet();
con = new SqlConnection( "Data Source=ServerName;Initial Catalog=DatabaseName;UserID=UserName;Password=Password" );
try
{
con .Open();
cmd = new SqlCommand("Select * from Tablename", con);
adp.SelectCommand = cmd;
adp.Fill(ds, "Tablename");
adp.Dispose();
cmd.Dispose();
con.Close();
}
catch (Exception ex)
{
}
using System.Data.SqlClient;
Code:
SqlConnection con;
SqlCommand cmd ;
SqlDataAdapter adp = new SqlDataAdapter();
DataSet ds = new DataSet();
con = new SqlConnection( "Data Source=ServerName;Initial Catalog=DatabaseName;UserID=UserName;Password=Password" );
try
{
con .Open();
cmd = new SqlCommand("Select * from Tablename", con);
adp.SelectCommand = cmd;
adp.Fill(ds, "Tablename");
adp.Dispose();
cmd.Dispose();
con.Close();
}
catch (Exception ex)
{
}
No comments:
Post a Comment