Solved

Updating data in database / datagrid

Posted on 2006-11-02
2
194 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
Comment Utility

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
Comment Utility
solved it myself
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Handling arrays 14 33
.Net Web Site Password specs 2 19
Round up to 100% in .NET 10 39
Convert to Hour/minute textbox and compare 3 33
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

7 Experts available now in Live!

Get 1:1 Help Now