S
santosh
Dear all i want to make connection with database using DNS i am trying
it in followin way but it gives me an error keyword not suppoerted dsn
can any one tell me what is the problem with in it.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!Page.IsPostBack)
{
SqlConnection cn =new SqlConnection();
SqlCommand cmd=new SqlCommand();
SqlDataAdapter da =new SqlDataAdapter();
DataSet ds =new DataSet();
cn.ConnectionString="DSN=TestDSN;Uid=sa;Pwd=sa";
cn.Open();
cmd.Connection=cn;
cmd.CommandText="select * from statemaster";
da.SelectCommand=cmd;
da.Fill(ds,"statemaster");
DataGrid1.DataSource=ds.Tables[0].DefaultView;
DataGrid1.DataBind();
}
}
here is web confing file code
<appSettings>
<add key="CnnString" value="DSN=TestDSN;Uid=sa;Pwd=sa" />
</appSettings>
any help greately apreciated.
it in followin way but it gives me an error keyword not suppoerted dsn
can any one tell me what is the problem with in it.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!Page.IsPostBack)
{
SqlConnection cn =new SqlConnection();
SqlCommand cmd=new SqlCommand();
SqlDataAdapter da =new SqlDataAdapter();
DataSet ds =new DataSet();
cn.ConnectionString="DSN=TestDSN;Uid=sa;Pwd=sa";
cn.Open();
cmd.Connection=cn;
cmd.CommandText="select * from statemaster";
da.SelectCommand=cmd;
da.Fill(ds,"statemaster");
DataGrid1.DataSource=ds.Tables[0].DefaultView;
DataGrid1.DataBind();
}
}
here is web confing file code
<appSettings>
<add key="CnnString" value="DSN=TestDSN;Uid=sa;Pwd=sa" />
</appSettings>
any help greately apreciated.