Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > INSERTING DATE

Reply
Thread Tools

INSERTING DATE

 
 
dthmtlgod
Guest
Posts: n/a
 
      10-11-2004
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')")



 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      10-11-2004
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.


 
Reply With Quote
 
 
 
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      10-11-2004
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" <(E-Mail Removed)> wrote in message
news:ui9$(E-Mail Removed)...
>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')")
>
>
>



 
Reply With Quote
 
Egbert Nierop \(MVP for IIS\)
Guest
Posts: n/a
 
      10-12-2004
"dthmtlgod" <(E-Mail Removed)> wrote in message
news:ui9$(E-Mail Removed)...
>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


>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Given a date, how to find the beginning date and ending date of that week Matt ASP General 11 11-08-2003 11:24 PM
Given a date, how to find the beginning date and ending date of that week Matt ASP .Net 1 11-08-2003 09:14 PM
Given a date, how to find the beginning date and ending date of that week Matt C Programming 3 11-08-2003 09:07 PM
Given a date, how to find the beginning date and ending date of that week Matt C++ 2 11-08-2003 08:30 PM



Advertisments