Here'e the code:I'm trying to access an Access database, and the @postedon parameter is supposed to be inserted into a field of type Date/Time and the format is General Date. I tried various OleDbType - DBTimeStamp, DBDate, Date, DBTime, Char - all resulted in "System.Data.OleDb.OleDbException: Data type mismatch in criteria expression." What is the right way to add dates?Code:Dim objConn As New OleDbConnection(strDSN) Dim objCmd As New OleDbCommand("nwsInsert", objConn) objCmd.CommandType = CommandType.StoredProcedure 'get the input time Dim dttDate As DateTime dttDate = Date.Now.UtcNow objParam = New OleDbParameter("@postedon", OleDbType.DBTimeStamp) objParam.Value = dttDate objCmd.Parameters.Add(objParam) 'execute the append objCmd.Connection.Open() objCmd.ExecuteNonQuery() objCmd.Connection.Close() objConn.Dispose()




Reply With Quote