>Should I use rowstate to check for modified rows? It seems to show modified whether there are changes or not. See example code below...
>
>Dim userid, password, servername, databasename, connectionstring As String
>Dim con As SqlClient.SqlConnection
>
>userid = "xxx"
>password = "xxx"
>servername = "xxx"
>databasename = "xxx"
>
>connectionstring = "UID=" & userid & ";" & _
> "PWD=" & password & ";" & _
> "Data Source=" & servername & ";" & _
> "Initial Catalog=" & databasename & ";"
>
>con = New SqlClient.SqlConnection()
>con.ConnectionString = connectionstring
>
>Dim tablename, keyname, strSelectedId As String
>Dim strSelect As String
>Dim selectcommand As SqlClient.SqlCommand
>Dim DS As DataSet
>Dim DT As DataTable
>Dim DA As SqlClient.SqlDataAdapter
>
>strSelectedId = "0000000007"
>tablename = "CALLTYPE"
>keyname = "ct_ctid"
>
>strSelect = "Select * from " & tablename & _
> " where " & keyname & "='" & strSelectedId & "'"
>selectcommand = New SqlClient.SqlCommand(strSelect, con)
>
>DA = New SqlClient.SqlDataAdapter(strSelect, con)
>DA.SelectCommand = selectcommand
>DA.SelectCommand.Connection = con
>DS = New DataSet()
>DA.Fill(DS, tablename)
>
>
>MsgBox(DS.Tables("Calltype").Rows(0).ItemArray(0)) ' show initial value
>DS.Tables("Calltype").Rows(0).BeginEdit() ' begin edit
>MsgBox(DS.Tables("Calltype").Rows(0).RowState.ToString) ' state is unchhanged
>DS.Tables("Calltype").Rows(0).EndEdit() ' end edit
>MsgBox(DS.Tables("Calltype").Rows(0).RowState.ToString) ' state is modified???
>
>How do I check for changes if they try to exit without saving?
>
>Kathy
Hi,Kathy.
I think you can use GetChanges method of DataTable.This method returns datatable with only changed rows.
Alex
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement