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

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
MarvelousMerlinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DhaestCommented:
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
TimCotteeHead of Software ServicesCommented:
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
MarvelousMerlinAuthor Commented:
Dhaest

There's no error.

TimCottee

I'll quickly try the before update

MM
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

MarvelousMerlinAuthor Commented:
TimCottee

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

MM
0
MarvelousMerlinAuthor Commented:
I've found that when i close the project the data gets updated.  and not during run-time.

??????

MM
0
MarvelousMerlinAuthor Commented:
sorry.......... when i STOP the project the data gets updated

MM
0
MarvelousMerlinAuthor Commented:
....no comments.......i'm battling with this one...plz help
0
DhaestCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MarvelousMerlinAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.