Need Coding Help With Updating Dataset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good day, I hoping someone can help me with a problem that I have. I'm trying
to update a dataset then my datasource using the sqlcommandbuilder in vb.net
2003. I only want to update fields that actually have been changed by the
user. So this is the code I have for one field as an example:

In my gotfocus method for each field I have the following 1 liner:
tmpWord = txtSchoolName.Text.ToString()

In my LEAVE method for each field I have the following with the respected
field name:
'trying to determine if the old string matches the new string
Dim intTemp As Int32 = String.Compare(tmpWord, txtcity.Text.ToString())
Select Case intTemp
Case 0
'Strings are the same, do nothing
Case 1
'Strings are different
ModifyDataSet("gcSchoolName")
End Select

The problem is in my ModifyDataSet Sub:
Private Sub ModifyDataSet(ByRef m_strField As String)
Dim intLoop As Integer

For intLoop = 0 To dsSConfig.Tables("sys_cfg").Rows.Count - 1
If String.Compare(dsSConfig.Tables("sys_cfg").Rows(intLoop)
("sysconfg").ToString(), _
m_strField) = 0 Then
dsSConfig.Tables("sys_cfg").Rows(intLoop)("defavalue") =
txtSchoolid.Text <- NEED TO CHANGE AND MAKE DYNAMIC
Exit Sub
How do I make the assigned value to the dataset dynamic for each field
name? All suggestions is greatfully appreciated. Thank you for your help.
 
Hi Terrance,

I am not sure I understand your question. First of all, instead of looping
through all the sysconfig rows, I'd recommend that you used a
System.Data.DataView filtered by the proper configuration setting name.

Your field value assignment code looks OK at the first glance, what do you
mean by saying "dynamic"?

The SqlDataAdapter will update only those rows in sysconfig which have been
changed (unless you manually call AcceptChanges on the DataSet which you
should practically never do in such a scenario).
 
Thanks for the help and input/insight.
--
TC


Dmytro Lapshyn said:
Hi Terrance,

I am not sure I understand your question. First of all, instead of looping
through all the sysconfig rows, I'd recommend that you used a
System.Data.DataView filtered by the proper configuration setting name.

Your field value assignment code looks OK at the first glance, what do you
mean by saying "dynamic"?

The SqlDataAdapter will update only those rows in sysconfig which have been
changed (unless you manually call AcceptChanges on the DataSet which you
should practically never do in such a scenario).
 
Back
Top