Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Type mismatch with "con.Execute "HELP!

Status
Not open for further replies.

iteach2

Technical User
Sep 16, 2001
120
US
For some reason I get the "Data type mismatch in criteria expression." error at the "con.Execute sqlupdate". WHAT AM I NOT DOING.



<%@Language=VBScript%>
<% Option Explicit %>


<%

' Setting variables
Dim con, sqlupdate, datasource, frmValue

datasource = &quot;essex&quot;

frmValue = request.form(&quot;datainfo&quot;)

sqlupdate = &quot;update tblcontent set content = 'frmvalue' where id = '1'&quot;

' Creating the Connection Object and opening the database

set con=Server.CreateObject(&quot;ADODB.Connection&quot;)

con.ConnectionString=&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & server.mappath(&quot;essex.mdb&quot;)

con.open

' Executing the sql update code

con.Execute sqlupdate

' Done. Now Close the connection

con.Close

Set con = Nothing
 
change to this

sqlupdate = &quot;update tblcontent set content = '&quot; & frmvalue & &quot;' where id = '1'&quot;
Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
Also, unless your id field is a string than you don't need the single quotes around it. If this is a numeric field than try:
sqlupdate = &quot;update tblcontent set content = '&quot; & frmvalue & &quot;' where id = 1&quot;

this is most likely the source of your error, while GaryC's fix will preemptively fix the error you woiuld have had of all of always setting the content field value equal to the word 'frmvalue'

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
Thanks GaryC123...But I'm still getting that error. Is there some other error in my code..you think?
 
you must ahve posted at the same time as Tarwn :eek:)
Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
Thanks Tarwn,

Still no luck though...Now I' getting
&quot;Error Type:
Microsoft JET Database Engine (0x80004005)
Operation must use an updateable query.&quot;

 
Try it like thi -

set conn=Server.CreateObject(&quot;ADODB.Connection&quot;)
strconn = &quot;DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=; DBQ=&quot; & Server.MapPath(&quot;essex.mdb&quot;)

conn.Open strConn

sql=&quot;update tblcontent set content = '&quot; & frmvalue & &quot;' where id = 1&quot;

conn.Execute sql, Recordsaffected Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
AAAARRRRGGG!!!!

Error Type:
Microsoft VBScript runtime (0x800A01F4)
Variable is undefined: 'Recordsaffected'

GaryC123 do I need to include adovbs.inc
 
You must have Option Explicit at the top of your asp page.

Add this to your page.

Dim Recordsaffected


Thanks,

Gabe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top