help me plz

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeronjaison
    New Member
    • Mar 2008
    • 2

    help me plz

    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
  • Stang02GT
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Your going to have to give us more detail about this code and what it is supposed to do.


    It appears once we get more information this would be more suited in the SQL forums

    Comment

    • arunr2008
      New Member
      • Jan 2008
      • 1

      #3
      You have specified the datasource both in the design time and the code-behind(run-time). You need to remove either of these two.

      Other wise you try with following code:-

      GridView1.DataS ource = ds;
      GridView1.DataS ourceID = String.Empty;

      Comment

      • smruti
        New Member
        • Mar 2008
        • 6

        #4
        [QUOTE=jeronjais on]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(+"','"+ 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.

        Comment

        Working...