Solved

Updating data in database / datagrid

Posted on 2006-11-02
2
200 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

729 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