question

Fullstop-7420 avatar image
0 Votes"
Fullstop-7420 asked Fullstop-7420 answered

Dynamic update query in Tableadapter (strongly typed dataset)

Hi
I have a strong typed dataset that has one table in it and is bound to a datagridview. I need to generate a dynamic update statement so I can update my datagridview on a cell change. So basically, when a cell is edited, I need to send the new value and the columname to the adapter an so it can update it respectively. I tried extending the adapter like this, but this seems to work only with select.. can someone help?




  public int UpdateNew(ScheduleTestDataSet.AppointmentsDataTable dataTable, string whereExpression)
         {
             string text1 = this.CommandCollection[2].CommandText;
    
             Debug.Print(text1);
             try
             {
                 this.CommandCollection[2].CommandText =  whereExpression;
                 Debug.Print(whereExpression);
                 return this.Fill(dataTable);
             }
             finally { this.CommandCollection[2].CommandText = whereExpression; }
         }



dotnet-csharpdotnet-adonet
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Fullstop-7420 avatar image
0 Votes"
Fullstop-7420 answered

this is a project that inherited, and it was so constructed back then, and it seems the only way around is to rewrite it :(

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered

When using a TableAdapter one must understand these containers before venturing in and using them.

The underlying code which most coders don't look at is under the covers and strongly typed, not very flexible and in your case not going to work.

If you stick with a TableAdapter and need things to be dynamic, you need to write code to handle what a TableAdapter does not natively.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.