Solved

Updating data in database / datagrid

Posted on 2006-11-02
2
196 Views
Last Modified: 2010-04-23
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!!!!!!!

0
Comment
Question by:JamesBrian
2 Comments
 
LVL 6

Accepted Solution

by:
manch earned 500 total points
ID: 17865761

for ur first problem :

make the datacolumn to ReadOnly for those columns u dont wanted to be editable
e.e.

ds.Tables(urTableNames).Columns(urColumnName).IsReadOnly = True

and then assign the daset to the DataGridView

try it
0
 

Author Comment

by:JamesBrian
ID: 17906315
solved it myself
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now