update RRS feed

  • Question

  • User-1161081280 posted

    how to write a update query for asp.net using session

    My session variable is this 

    DataSet var = (DataSet)Session["dsReturn"];
    int iRowIndex = usergridview.SelectedIndex;

    now how to update database using this variable primary key is ID. 

      Tower Articlno Category Tester Date Problem Solution ID
    Select PBTS102 2 EEID Usha   The Problem Exists in EEID programming The Problem Exists in EEID programming 2
    Tuesday, July 22, 2014 4:43 AM


  • User1918509225 posted

     Hi Prasun,

    For your post,here are my suggestion:

    First ,I am not sure where you get the variable primary Key ID ,is it the iRowIndex?

    Second ,In your code ,where did you get the value of Tower,Acticlno Category,

    Did you get the value from the session Or Other else?

    Third,If the column values you need to update are not from Session,I think you can just

    Update the database like below:

    String query = @"update table name set  Tower=@tower and Category =@Categorywhere ID=@ID";
    using(SqlCommand cmd = new SqlCommand(query, conn)){
      string tower= get  value from someplace;
      string category =get value from someplace;
       int id=get value from someplace;
    cmd.Parameters.AddWithValue("@tower ", tower);
    cmd.Parameters.AddWithValue("@Category ", category );
    cmd.Parameters.AddWithValue("@ID", id);

    Best Regards,

    Kevin Shen.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 22, 2014 9:45 PM