Link to home
Start Free TrialLog in
Avatar of JamesBrian
JamesBrian

asked on

Updating data in database / datagrid

Hi all,

I fill my datagrid using this code :
Private Sub LoadData()
        'Construct data adapter
        SelectCmdString = "select * from SMSQUEUE WHERE Acknowledged=0 order by SMSQueueID"
        da = New SqlDataAdapter(SelectCmdString, conn)
        da.Fill(ds, "SMSQUEUE")
        LabelID.DataBindings.Add("Text", ds, "SMSQUEUE.smsqueueid")
        LabelDate.DataBindings.Add("Text", ds, "SMSQUEUE.createdon")
        LabelDestination.DataBindings.Add("Text", ds, "SMSQUEUE.destination")
        LabelDescription.DataBindings.Add("Text", ds, "SMSQUEUE.description")
        DataGrid1.SetDataBinding(ds, "SMSQUEUE")
        Timer1.Interval = CInt(myInterval) * 1000
        Timer1.Enabled = True

    End Sub

This gives a Datagrid with 13 columns
I only want the 8th column to be editable(boolean, so just click on/off)
If the checkin this row has been changed, I need to update the 1st and 5th column with a timestamp and the user that performed the update.
I also need to be able to do this in batch.

Now, I am saving changes to other columns in batch like this :

SelectCmdString = "select * from SMSQUEUE WHERE Acknowledged=0 order by SMSQueueID"
        Dim strUser As String = UCase(InputBox("Your Login Name?", "Security"))
        If Verify_user_Settings(PrivGroup, DomController, strUser) Then
            If ds.HasChanges() Then
                Dim da As SqlDataAdapter
                Dim command_builder As SqlCommandBuilder
                 da = New SqlDataAdapter(SelectCmdString, conn)
                da.TableMappings.Add("Table", "SMSQUEUE")
                 command_builder = New SqlCommandBuilder(da)
                 da.Update(ds)
                MsgBox("Changes have been Committed")
            End If
        Else
            MsgBox("Group Security Policies denies you changing data.")
        End If

Any suggestions ?
I HATE ADO.NET !!!! Things I always found easy are sudenly hard to do...... GRRRRRRR!!!!!!!

ASKER CERTIFIED SOLUTION
Avatar of Manish Chhetia
Manish Chhetia
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JamesBrian
JamesBrian

ASKER

solved it myself