?
Solved

Datagrid and MS DB updating??  Everything looks fine but not updating??????

Posted on 2005-03-09
9
Medium Priority
?
173 Views
Last Modified: 2008-02-01
Hi there ppl

I have a Datagrid on a form, I've set the datasource during the Form Load Event.  I've done all the do's and don'ts of datagrid.
It worked fine and I moved on to different part of my program.  Now the Datagrid doesn't update the MS DB anymore?????
Help!!!!!

This is the code i'm using:

Private Sub Form_Load()

ChangeWeight
RefreshGridLearners
RefreshGridDeleteLearners
RefreshGridMarks                       '''This is the one that's got the problem

End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Private Sub RefreshGridMarks()

Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim SQLFieldNames As String

Dim i As Integer
Dim x As Integer
Dim length As Integer

bindFieldNames

i = 0
x = 1

Do Until (i = 16)
    If (fieldNames(i) > "") Then
            SQLFieldNames = SQLFieldNames & " Proj" & x & " as [" & projname(i) & "]"
            i = i + 1
            x = x + 1
            If i = 16 Then
            Else
                SQLFieldNames = SQLFieldNames & ","
            End If
    Else
    GoTo EndOfProjects
    End If
Loop

EndOfProjects:

SQLFieldNames = SQLFieldNames & " ProjTotal, Exam, Rapportmark"

conn.Open connectString

Set DataGrid2.DataSource = Nothing
Set rs = Nothing

rs.CursorLocation = adUseClient
rs.Open "SELECT StudentNum, Name, Surname, " & SQLFieldNames & " FROM Data WHERE Subject = '" & sSubject & "' AND Grade = " & iGrade & " AND Class = '" & iClass & "' AND Term = '" & sTerm & "' ORDER BY Surname", conn, adOpenDynamic, adLockBatchOptimistic

rs.Requery

DataGrid2.AllowUpdate = True
Set DataGrid2.DataSource = rs

End Sub


Everything looks fine....

i have a routine         Private Sub DataGrid2_AfterColUpdate(ByVal ColIndex As Integer)

that does calculations in the datagrid, these calculations is displayed correctly in the datagrid but doesnt get updated in the MSDB.

Help!!!!!!!!!!

MM
0
Comment
Question by:MarvelousMerlin
[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
  • 6
  • 2
9 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 13494066
Do you get an errormessage ?
Put an errorhandler in it and let us know what error you get !

Private Sub RefreshGridMarks()
on error goto RefreshGridMarksError
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim SQLFieldNames As String

Dim i As Integer
Dim x As Integer
Dim length As Integer

bindFieldNames

i = 0
x = 1

Do Until (i = 16)
    If (fieldNames(i) > "") Then
            SQLFieldNames = SQLFieldNames & " Proj" & x & " as [" & projname(i) & "]"
            i = i + 1
            x = x + 1
            If i = 16 Then
            Else
                SQLFieldNames = SQLFieldNames & ","
            End If
    Else
    GoTo EndOfProjects
    End If
Loop

EndOfProjects:

SQLFieldNames = SQLFieldNames & " ProjTotal, Exam, Rapportmark"

conn.Open connectString

Set DataGrid2.DataSource = Nothing
Set rs = Nothing

rs.CursorLocation = adUseClient
rs.Open "SELECT StudentNum, Name, Surname, " & SQLFieldNames & " FROM Data WHERE Subject = '" & sSubject & "' AND Grade = " & iGrade & " AND Class = '" & iClass & "' AND Term = '" & sTerm & "' ORDER BY Surname", conn, adOpenDynamic, adLockBatchOptimistic

rs.Requery

DataGrid2.AllowUpdate = True
Set DataGrid2.DataSource = rs
exit sub
RefreshGridMarksError:
 msgbox err.number & " " & err.description  
End Sub
0
 
LVL 43

Assisted Solution

by:TimCottee
TimCottee earned 800 total points
ID: 13494096
Hi MarvelousMerlin,

Why have an "After" col update event? This will fire after the database has been updated. Logically then it will not be able to update the database itself. Perhaps you should use Before_ColUpdate event instead.

Tim Cottee
0
 

Author Comment

by:MarvelousMerlin
ID: 13494231
Dhaest

There's no error.

TimCottee

I'll quickly try the before update

MM
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MarvelousMerlin
ID: 13494306
TimCottee

Stil doesn't update the DB.  Even with the Before update

MM
0
 

Author Comment

by:MarvelousMerlin
ID: 13494592
I've found that when i close the project the data gets updated.  and not during run-time.

??????

MM
0
 

Author Comment

by:MarvelousMerlin
ID: 13494604
sorry.......... when i STOP the project the data gets updated

MM
0
 

Author Comment

by:MarvelousMerlin
ID: 13563676
....no comments.......i'm battling with this one...plz help
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 1200 total points
ID: 13563806
Take a look at the following:
PRB: DataBound Controls Not Updated with DataEnvironment Using Refresh Method
http://support.microsoft.com/default.aspx?scid=kb;en-us;216666&Product=vb6
0
 

Author Comment

by:MarvelousMerlin
ID: 13599248
Dhaest

Thanks for help.....didn't work.....
Changed to True DBGrid.  Working great.

But i'll splitt the spoints between you and TimCottee.  Just for ure effort.

THANKS

I've got another braintwister:  see if u could help plz:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21359729.html
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 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