Date and Time in MS Access


I write my third ASP.NET project. It's a customer survey. The data will be stored in an Access-database, which shall contain the client data and additional the Date/Time of the entry.

Here is my INSERT-function:

Function Survey_Insert(ByVal projektnummer As String, ...) As Integer
    Dim connectionString As String = "Provi...Survey.mdb"
    Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
    Dim Zeit as New DateTime
    Dim queryString As String = "INSERT INTO [Ergebnis] ([Projektnummer], [Form], [Umfang], [Inhalt], [Technik],"& _
        " [Konditionen], [Kompetenz], [Kommentar], [Bestell], [Anfrage], [Eintrag]) VALUES (@Projektnummer, @For"& _
        "m, @Umfang, @Inhalt, @Technik, @Konditionen, @Kompetenz, @Kommentar, @Bestell, @Anfrage, @Eintrag)"
    Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
    dbCommand.CommandText = queryString
    dbCommand.Connection = dbConnection
    ' Parameterentries
    Dim dbParam_projektnummer As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
    ' TimeStamp Parameter
    Dim dbParam_eintrag As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
    dbParam_eintrag.ParameterName = "@Eintrag"
    dbParam_eintrag.Value = Zeit.Now
    dbParam_eintrag.DbType = System.Data.DbType.DateTime
    Dim rowsAffected As Integer = 0
        rowsAffected = dbCommand.ExecuteNonQuery
    End Try
    Return rowsAffected
End Function

Problem: The database and ASP.NET use the same date notation (DD.MM.YYYY hh:mm:ss), but I got an error with this script and I don't know why? Aren't that the same object types?
It seams very simple, but I can't manage it Sad [:(] and need some help!!!

Thx and greetz! Carlsson

3/29/2005 3:21:47 PM 4679 articles. 0 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 11

You did not paste your error message.Can you paste it then we can have beeter idea.


3/29/2005 8:02:04 PM
did you paste only part of your code or is this what yo have ? if so where do you have the other parameters declared?  I only see the declaration for one parameter, you need to add each of the paremeters that you have in your sql statement and give a value for each of them and in the same order as they appear in the sql.
Dinakar Nethi
Life is short. Enjoy it.
3/29/2005 8:30:34 PM

The code is only a fragment. If I delete the date-param, all other parameters work fine. I've deleted things and replaced them through points ("...") to get a shorter post.

I used the exception handler yesterday and received following error message:

System.Data.OleDb.OleDbException: Datentypen in Kriterienausdruck unverträglich.(Datatypes in expression incompatible) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at ASP.Survey_deu_aspx.Survey_Insert(String projektnummer, String form, String umfang, String inhalt, String technik, String konditionen, String kompetenz, String kommentar, Boolean bestell, Boolean anfrage) in C:\Inetpub\wwwroot\Survey\Survey_deu.aspx:line 128

Datatypes incompatible? Both are DateTime-objects, aren't they? And with the same german format-notation....(see above). I play with this problem between Access and ASP.NET since yesterday morning, harvested nearly every ASP- and ASP.NET-Page and can't find a mistake. I'm going mad! Super Angry [8o|]

For information: The code was generated by WebMatrix and is only slightly modified.

Does anybody have a solution??? PLEASE!!! => Good for my nerves. Smile [:)]

Greetz carlsson!


3/30/2005 8:35:43 AM

I've got it! Big Smile [:D] Party!!! [<:o)]

Initialize the parameter-value with a string, left the parameter-type as DateTime and it will work! Weird but true!

Here's the changed code-fragment:
' TimeStamp Parameter
Dim dbParam_eintrag As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_eintrag.ParameterName = "@Eintrag"
dbParam_eintrag.Value = Zeit.Now.ToString
dbParam_eintrag.DbType = System.Data.DbType.DateTime

Greetz! Carlsson

3/30/2005 3:04:16 PM

Similar Artilces:

DBI, MS Access, inserting/updating a Access Date/Time value
Hi, Does anyone have any idea what is up with Microsoft Access and its ridiculous Date/Time formatting options? It doesn't seem to matter what format I attempt to insert with. The directory and db file permissions are all Full Control. I'm using the "#" around the Date/Time format as required. The database has nothing as the Format in Design view on the General tab. The insert below has never worked once. On the up side if I run an insert that has no mention of the Date/Time field then it will just insert the record using the =Now() function as the default va...

accessing MS Access from .net
hi I am accessing ms access data base which has a table called customers. when i try to insert data into the table i am gettign the error like "Operation must use an updatable query" and the line its showing is myOleDbcommand.ExecuteNonQuery() here is my code in page lode event Sub Page_Load(Sender As Object, E As EventArgs) Dim StrConnectString as String Dim strStatement as String strConnectSTring = "Provider=Microsoft.Jet.OLEDB.4.0;Password='';User ID=Admin;Data Source=C:\Inetpub\wwwroot\Srinu\WebApplication2\...

Retrieve Only Date from Date/Time in Ms Access
Hello,When retrieving data from an ACCESS database table, I want the generated ASP page to display only the date inputted by the user. It currently displays the date and then the time is always 12:00. Anyone have any suggestions as how I can have it display only the time, but leave the access format as Date/Time? Format the output - use {0:d} Something like:label1.text=String.Format("{0:d}",YourDate)David WierMCP/ - where to look first!Please Vote for ASPNet101 - 'Best Community Resource'!Control Grouper - easily control properties for multipl...

GridView data table and MS Access table. Some time I like MS Access...
Hi: I want all the rows and coloums data showing in the GridView can be editable, just like the MS Access table on the form, you can modify and update any cell and it will be saved if your mouse leave that cell (or you click "Save" button). The reason I ask is: everyday I have about hundrands of data need to be set the date(Today's date), to be set the status (on/off), and input Receipt Num, if I using Gridview's "Edit" "Update" feature, I find there are still two many clicks, and also the selected rows changing the size and p...

How to remove the date part of a Date/Time value in MS Access
I am inserting a time value into a MS Access Date/Time field and notice that MS Access does not display the date portion of the value but when I look at the same data in my programming using a TADOTable component I am seeing the date of 12/30/1899 in conjunction with my time value. I read that Access is handling this within MS Access so that when a 0.sometime value is inserted it does not display the date. How do I handle this within my Delphi program so that I can display the time only in a Date/Time type field? Jeff Howard wrote: > I am inserting a time value into a MS Access Date/T...

Accessing MS Access
Hi all, This is probably a more DB oriented question, but it came out of the = DBI. I posted a question and have tried several solutions on how to open = up an MS Access DB from the DBI::ODBC but so far have been unable to. = What I had to end up doing was create a DTS that runs every 5 minutes = which copies the table I need from Access and populates a SQL Server = table. This causes a delay on my web application such that whenever my = page overlaps while the DTS is running I get no data. So I was wondering = if there is a better way to get information from Access so I can see it =...

MS access to MS access problem
I always used MS Access Database In my programs, now I want to use SQL SERVER database and so I started to design one. but it’s a little bit confusing ,I don’t know what can I use in change of these access Data type : MS access // MS access -------------- -------------------- Memo >>>>>>>> ?? AutoNumber >>>>> ?? * and if you think there is some difference between Ms access and SQL in D...

accessing access
------=_NextPart_000_029B_01C29063.1E2098D0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi! I am trying to access an access mdb file for the first time. I get the following error: Can't connect(dbi::ODBC:pfawtbls.mdb ), no database driver specified and DBI_DSN env var not set at line 147 for the code: my $dbh = DBI->connect( "dbi::ODBC:pfawtbls.mdb", "", "", ) or die "Unable to connect: ". $DBI::errstr. "<br>"; What am I missing? Thanks, Jer...

Problems with MS Access Date Time
I am using PB 701 with a Microsoft Access Database. Whenever I try to update a data window with a date time column in it I get an syntax error message on theupdate or insert statement. It is trying to insert the datetime in the form {ts 2001-12-02 }. Any help would be greatly appreciated. Edney Holder In the pbodb70.ini file you specify the format that PB7 will use. Check the [Access] section. Mine is set to: PBDateTime='NO_MSECS_DATETIME' Now look further down in the file and find the section ; **************************************************...

Access access
========== Hi, Everyone ... I'm going to lock this thread for now. If you have a question about working with Access in Web Matrix, please start a new thread in this forum. Otherwise, this thread will get to be unwieldy. Thanks! ========== Updated 6/29/03 Hello, everyone. I've been working with the new version of Web Matrix (version .6, build 812, available right now!). In particular, I've been playing with support for Microsoft Access, which is one of the great new features in the new release. I wrote up some notes on what I've found to share some of my experiences and to a...

how can I access MS Access db on the remote website, at design-time?
Hello! I have a remote website, which I open using Visual Studio. And there is located my data.db access file. Is it possible to create Dataset at design time, which will read the data from that db? When I create the dataset, and trying to add database, there is Oledb data provider, but it wants to work only with local files I need to add design-time dataset, to use them in ReportView. Thank you in advanceArtashes...

Accessing a MS Access database
Hi, I would like to do a lookup into an Access database, and display the result in a grid. I'm an embedded programmer being thrown into the world of .net, asp, VB, and databases so I don't know where to start :-) ...... can anyone help me ? Thanks. Really jus ta matter of making a connection, doing your query, and displaying results. Here is a sample from a module I use. The data is bound to a datagrid. Sub LoadSchedule() Dim strSrc As String = CType(Settings("src"), String) If Trim(strSrc) <> "" Then ...

Access to MS-Access denied
I'm moving data from MS-Access *.mdb files (using Win32::ODBC) to a postgresql database (using DBD:Pg). While I'n not having problems to do it with many ordinary *.mdb files I'm unable now to transfer data from an Access file which is protected. As a matter of fact the launching icon on my NT desktop has the following line in it (which gives me r/w rights on the db): "C:\programs\Microsoft Office\Office\MSACCES.EXE""V:\PE\myfile.mdb/user De Martino/nostartup". I've tried to give the login "De Martino" (no password is required) to the ...

DBD::Access? [was: MS Access]
The message further below went accidentally not to the list... > Tim Harsch wrote: > > Forgive my naivity (or just flawed understanding) but how would one go > about creating a DBD::Access? For instance DBD::Oracle is built on > OCI, does Access have a similar network protocol? I thought that ODBC > was about the only MS supported method of communicating to it... One of the earlier mails said: > > From: Tim Bunce > > On Tue, Jun 25, 2002 at 10:27:20AM -0700, Jeff Zucker wrote: > > > Orlando Andico wrote: > > > > > >...

Web resources about - Date and Time in MS Access -

Random-access memory - Wikipedia, the free encyclopedia
Random access memory ( RAM ) is a form of computer data storage . A random access device allows stored data to be accessed in any order in very ...

Feature Request: Give Siri access to third-party apps, and (in time) much more
... with it right now is that I have all these apps on my phone that can answer lots of questions and do lots of things, but Siri has no access ...

DNC suspends Sanders campaign’s access to party voter file
... Sanders’s campaign is cut off from the Democratic Party’s 50-state voter file following a glitch that gave a Sanders staffer unauthorized access ...

DNC Agrees To Give Voter Data Access Back To Sanders Campaign
The presidential campaign filed a lawsuit in federal court Friday after the Democratic National Committee barred its aides from accessing voter ...

Under pressure, DNC restores Bernie Sanders campaign's access to their database - Videos - CBS News
... of a shared data system, costing them hundreds of thousands of dollars a day, but after viral petitions, the DNC restored the campaigns access ...

Bernie Sanders and the DNC reach a deal on voter file access
CNN Bernie Sanders and the DNC reach a deal on voter file access CNN Washington (CNN) [Breaking news update, Saturday 12:10 a.m. ET]. A deal ...

Bernie Sanders Will Get His Data Access Back
Bernie Sanders will have his voter file access restored to him Saturday morning, according to the DNC and the Sanders campaign. Buzzfeed has ...

Sanders Campaign Sues DNC For Shutting Off Access To Voter File
Sanders Campaign Sues DNC For Shutting Off Access To Voter File

DNC restores Sanders campaign access to voter file
... request to provide the information that we have requested of them. Based on this information, we are restoring the Sanders campaign’s access ...

Resources last updated: 12/20/2015 1:19:12 AM