Connection with sql server 2000 using DSN

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top