Hi I've searched all over the internet for this but can't find anything useful. I have form which a user fills out and then inserts in access database. But I also have a field DateTime in my table which I want to automatically save the current date and time in the database. How do I do this? Thank you. I keep getting an error saying "an oledbparameter with parameter name '@datetime' is not contained by this oledb"
Try
con.Open()
With cmd
.Connection = con
.CommandType = CommandType.Text
.CommandText = "INSERT INTO tJ (S, T, DateTime) VALUES (@S, @T, @DateTime)"
.Parameters.Add(New System.Data.OleDb.OleDbParameter("@S", System.Data.OleDb.OleDbType.VarChar, 255, Me.cmbN.Text))
.Parameters.Add(New System.Data.OleDb.OleDbParameter("@T", System.Data.OleDb.OleDbType.VarChar, 255, Me.cmbT.Text))
.Parameters.Add(New System.Data.OleDb.OleDbParameter("DateTime", System.Data.OleDb.OleDbType.Date))
cmd.Parameters("@S").Value = Me.cmbN.Text
cmd.Parameters("@T").Value = Me.cmbT.Text
cmd.Parameters("@DateTime").Value = Date.Now
cmd.ExecuteNonQuery()
MsgBox("saved.", MsgBoxStyle.Information)