You must Sign In to post a response.
  • Category: .NET

    Need detail about insert query

    Hi Friends
    I am trying to insert value from one table to another table.

    this is my query
    -----------------------
    cmd.CommandText = "INSERT INTO UGDCOLPOST(UGDCOLPOST.UGD_SRCKNO,UGDCOLPOST.UGD_ASSTNO,UGDCOLPOST.UGD_FINYR,UGDCOLPOST.UGD_HFYR,UGDCOLPOST.UGD_AMT,UGDCOLPOST.UGD_DATE,UGDCOLPOST.UGD_FLAG,UGDCOLPOST.UGD_AFLAG) SELECT ('" + txtugdrecno.Text + "','" + txtassno.Text + "',UGDDEMDET.UGD_FINYR,UGDDEMDET.UGD_HFYR,UGDDEMDET.UGD_DEM,UGDDEMDET.UGD_DT,'C','B') FROM UGDDEMDET WHERE UGDDEMDET.UGD_ASSTNO='" + txtassno.Text + "' AND UGDDEMDET.UGD_COLFLAG='0'";
    -----------------------------
    when i was click insert button its showing "ORA-00907: missing right parenthesis" error.can any one guide me.
  • #725241
    Please try this.

    I see brackets in select query. I think it is not required

    cmd.CommandText = "INSERT INTO UGDCOLPOST(UGDCOLPOST.UGD_SRCKNO,UGDCOLPOST.UGD_ASSTNO,UGDCOLPOST.UGD_FINYR,UGDCOLPOST.UGD_HFYR,UGDCOLPOST.UGD_AMT,UGDCOLPOST.UGD_DATE,UGDCOLPOST.UGD_FLAG,UGDCOLPOST.UGD_AFLAG) SELECT '" + txtugdrecno.Text + "','" + txtassno.Text + "',UGDDEMDET.UGD_FINYR,UGDDEMDET.UGD_HFYR,UGDDEMDET.UGD_DEM,UGDDEMDET.UGD_DT,'C','B' FROM UGDDEMDET WHERE UGDDEMDET.UGD_ASSTNO='" + txtassno.Text + "' AND UGDDEMDET.UGD_COLFLAG='0'";

    Please mark this as Answer, if this helps

    Regards,
    Alwyn Duraisingh.M 
    << Database Administrator >>
    Jesus saves! The rest of us better make backups...

  • #725375
    Hi,

    I agree with alwyn bracket is not neccessary when you use more than one column and make sure your textbox value is column name then don't use single quote remove that otherwise use single quote and try like this


    md.CommandText = "INSERT INTO UGDCOLPOST(UGDCOLPOST.UGD_SRCKNO,UGDCOLPOST.UGD_ASSTNO,UGDCOLPOST.UGD_FINYR,UGDCOLPOST.UGD_HFYR,UGDCOLPOST.UGD_AMT,UGDCOLPOST.UGD_DATE,UGDCOLPOST.UGD_FLAG,UGDCOLPOST.UGD_AFLAG) SELECT " + txtugdrecno.Text + "," + txtassno.Text + ",UGDDEMDET.UGD_FINYR,UGDDEMDET.UGD_HFYR,UGDDEMDET.UGD_DEM,UGDDEMDET.UGD_DT,'C','B' FROM UGDDEMDET WHERE UGDDEMDET.UGD_ASSTNO='" + txtassno.Text + "' AND UGDDEMDET.UGD_COLFLAG='0'

    Regards
    N.Ravindran
    Your Hard work never fails

  • #725630
    Hi

    please remove the bracket before select statement
    and better and less on UI please use Store proc


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.