VB.NET/MS ACCESS Fill column and all entries in the that column with the current date
-
I want to fill all the entries in a column with the current date so that I can compare it to a DateofTest column and determine how many days since the last test. I think I can figure out the number of days but I can't figure out how to fill the column with the current date.
Private Sub Reports_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
mySql = "Update Studentdata, SET currentDate = Date()"
ConnDB()
myCommand = New OleDbCommand(mySql, myConnection)End Sub
-
I want to fill all the entries in a column with the current date so that I can compare it to a DateofTest column and determine how many days since the last test. I think I can figure out the number of days but I can't figure out how to fill the column with the current date.
Private Sub Reports_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
mySql = "Update Studentdata, SET currentDate = Date()"
ConnDB()
myCommand = New OleDbCommand(mySql, myConnection)End Sub
Remove the comma.
UPDATE StudentData SET currentDate = DATE()"
Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.
-
Remove the comma.
UPDATE StudentData SET currentDate = DATE()"
Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.
No luck. I don't get an error it just doesn't do anything to the column.
-
I want to fill all the entries in a column with the current date so that I can compare it to a DateofTest column and determine how many days since the last test. I think I can figure out the number of days but I can't figure out how to fill the column with the current date.
Private Sub Reports_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
mySql = "Update Studentdata, SET currentDate = Date()"
ConnDB()
myCommand = New OleDbCommand(mySql, myConnection)End Sub
-
No luck. I don't get an error it just doesn't do anything to the column.
As Richard pointed out, if you have shown all of your code you are never actually executing it.
Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.
-
doesn't this execute the command? myCommand = New OleDbCommand(mySql, myConnection)
-
That did the trick. I added mycommand.ExecuteNonQuery() and it worked perfect.
-
doesn't this execute the command? myCommand = New OleDbCommand(mySql, myConnection)
No, it just creates a OldDbCommand object. You actually have to tell it to execute using one of the Execute... methods.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak