473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

INSERTING DATE

I am trying to insert a date into a date field through my website. The date
is pre-populated with todays date. I am getting a type mismatch error. The
Access DB is setup as a Date/Time Short Date field.

Here is the SQL string. Any ideas?

Conn.execute ("INSERT INTO PrinterMaintenance (MaintDate, SA, Maintenance,
PrinterName, UserName) VALUES ('MaintDate', 'SA', 'Maintenance',
'PrinterName', 'UserName')")

Jul 19 '05 #1
3 1363
dthmtlgod wrote:
I am trying to insert a date into a date field through my website.
The date is pre-populated with todays date. I am getting a type
mismatch error. The Access DB is setup as a Date/Time Short Date
field.

Here is the SQL string. Any ideas?

Conn.execute ("INSERT INTO PrinterMaintenance (MaintDate, SA,
Maintenance, PrinterName, UserName) VALUES ('MaintDate', 'SA',
'Maintenance', 'PrinterName', 'UserName')")


This statement is attempting to put the word 'MaintDate' into a field that
will only accept date/time values.

Check out these posts:
http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl

http://www.google.com/groups?hl=en&l...%3D10%26sa%3DN

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #2
With what you have, you're trying to insert the literal text, "MaintDate."
You want to insert a date, i.e.

Conn.Execute "INSERT INTO PrinterMaintenance (MaintDate, SA, Maintenance,
PrinterName, UserName) VALUES (#" & Date & "#,'SA'......)"

Also, do you mean to insert the literal text of SA, Maintenance,
Printername, etc.? Or are they variables? If those are variables in your
code, they are not going to be evaluated when you execute your INSERT. All
you'll see is the actual literal text, MaintDate, SA, etc. Remember, you're
just building a string here, so if you want to concatenate variable values,
you have to do just that - concatenate the values.

sSQL = "INSERT INTO.... VALUES (#" & Date & "#,'" & SA & "','" & Maintenance
& "','" & PrinterName & "','" & Username & "')"

Response.Write sSQL

Ray at home

"dthmtlgod" <do*************@netzero.net> wrote in message
news:ui**************@TK2MSFTNGP10.phx.gbl...
I am trying to insert a date into a date field through my website. The
date
is pre-populated with todays date. I am getting a type mismatch error.
The
Access DB is setup as a Date/Time Short Date field.

Here is the SQL string. Any ideas?

Conn.execute ("INSERT INTO PrinterMaintenance (MaintDate, SA, Maintenance,
PrinterName, UserName) VALUES ('MaintDate', 'SA', 'Maintenance',
'PrinterName', 'UserName')")

Jul 19 '05 #3
"dthmtlgod" <do*************@netzero.net> wrote in message
news:ui**************@TK2MSFTNGP10.phx.gbl...
I am trying to insert a date into a date field through my website. The
date
is pre-populated with todays date. I am getting a type mismatch error.
The
Access DB is setup as a Date/Time Short Date field.

Here is the SQL string. Any ideas?

Conn.execute ("INSERT INTO PrinterMaintenance (MaintDate, SA, Maintenance,
PrinterName, UserName) VALUES ('MaintDate', 'SA', 'Maintenance',
'PrinterName', 'UserName')")
Use parameters

Set cmd.ActiveConnection = conn
cmd.CommandText = "insert into blah (dt) values(?)" ' simplified sample
cmd.CommandType = adCmdText
cmd.Parameters.Append cmd.CreateParameter(, adDBDate, 1, , Date)
cmd.Execute ,, adExecuteNoRecords




Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
3
by: J. Muenchbourg | last post by:
while inserting new records into SQL, i'm using the folloinwg sqlstatement> Dim MySQL as string = "Insert into roster (pname, pnotes, thedate) values (@pname, @pnotes, @thedate)" the sql...
15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
1
by: Smitty | last post by:
From the psql command line, I am having absolutely no problems inserting a NULL value into a date datatype field. When attempting to insert a NULL value via my Web app using SQL Relay, I am...
0
by: Niketa Mahana | last post by:
Hi, We are in the process of making product in windows forms that is localized presently for all european countries.We are supposed to support all eastern and western european date , time and...
6
by: fniles | last post by:
I am using VB.NET 2003 and SQL Server 2000. I have a table with a datetime column type. When inserting into the table for that column, I set it to Date.Now.ToString("T") , which is something like...
2
by: Luqman | last post by:
Hi, Any Idea how to Display Todays Date in DetailView Template Field while Inserting ? For example: When I click on New Button of DetailView Control, I need to display Today's Date in a...
13
by: imnewtoaccess | last post by:
Hi, I am getting errors while inserting records in one table from another. These are the structures of two tables : file51tm_new RecordType Text
20
by: dav3 | last post by:
Alright folks I am in need of a lil guidance/assistance here. I have a program which reads in a txt file. This txt file contains lines of the form January 3, 2007, 85.8 Now each line of the txt...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.