MarvelousMerlin
asked on
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(B yVal 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
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(B
that does calculations in the datagrid, these calculations is displayed correctly in the datagrid but doesnt get updated in the MSDB.
Help!!!!!!!!!!
MM
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dhaest
There's no error.
TimCottee
I'll quickly try the before update
MM
There's no error.
TimCottee
I'll quickly try the before update
MM
ASKER
TimCottee
Stil doesn't update the DB. Even with the Before update
MM
Stil doesn't update the DB. Even with the Before update
MM
ASKER
I've found that when i close the project the data gets updated. and not during run-time.
??????
MM
??????
MM
ASKER
sorry.......... when i STOP the project the data gets updated
MM
MM
ASKER
....no comments.......i'm battling with this one...plz help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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:
https://www.experts-exchange.com/questions/21359729/Datareport-not-refreshing.html
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:
https://www.experts-exchange.com/questions/21359729/Datareport-not-refreshing.html
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