hey i got an errror in my program can u help me............. .....
using system.data;
using system.data.sql client;
sqlconnection con;
sqlcommand cmd;
slqdataadapter da;
dataset ds;
pageload
{
sqlconnection con=new sqlconnection(" server=.;databa se=employee;uid =sa");
con.open();
sqlcommand cmd=new sqlcommand("sel ect * from emp",con);
da=new sqldataadapter( cmd);
ds=new dataset();
da.fill(ds,"emp ");
gridview1.datas ource=ds.table["emp"];
gridview1.datab ind();
}
btninsert_click
{
sqlcommand cmd=new sqlcommand("ins ert into emp values('"+ TextBox1.Text +"','"+ TextBox2.Text +"',con);
cmd.executenonq uery();
displaydata();
clear()
}
the exception is given below.
System.InvalidO perationExcepti on: Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition.
can any help me to solve this
using system.data;
using system.data.sql client;
sqlconnection con;
sqlcommand cmd;
slqdataadapter da;
dataset ds;
pageload
{
sqlconnection con=new sqlconnection(" server=.;databa se=employee;uid =sa");
con.open();
sqlcommand cmd=new sqlcommand("sel ect * from emp",con);
da=new sqldataadapter( cmd);
ds=new dataset();
da.fill(ds,"emp ");
gridview1.datas ource=ds.table["emp"];
gridview1.datab ind();
}
btninsert_click
{
sqlcommand cmd=new sqlcommand("ins ert into emp values('"+ TextBox1.Text +"','"+ TextBox2.Text +"',con);
cmd.executenonq uery();
displaydata();
clear()
}
the exception is given below.
System.InvalidO perationExcepti on: Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition.
can any help me to solve this
Comment