Solved

Updating data in database / datagrid

Posted on 2006-11-02
2
201 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

630 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