473,897 Members | 2,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

asp: type mismatch and update loop

I actually have two issues/questions:

I have an autonumber field in an access db table that I grab and later use to update a record in another table withing the same db.

The code I use to get it from the db table is:
''Retrieve the Registration Identification Number
strRegisterID = Rs("Register_ID ")

Prior to testing my code and actually updating the db, I''m trying to write it to the page to make sure their isn''t a loop or massive problem with my code.

I''m writing to the page like this:

for each objItem in request.Form()
if left(objItem,5) ="cksub" and request.Form(ob jItem) <> "" then
response.write( "strRegiste rID = ")
response.write( strRegisterID)
tempsub=request .form(objItem)
response.write( "tempsub = ")
response.write( tempsub)
end if
tempsub = ""
next

When I do this, I''m getting a type mismatch error.
Question 1: Is this because I''m in the "for each objItem" loop that doesn''t want to use the strRegisterID?

* * * * * * * * * * * * * * * * * * * * * * * * * * *
My next issue is updating two separate tables within the same database using two recordsets. I''ve created the following code for the update and want to know if anyone can tell if I''m on track or if my code is wacko. The end result is taking information from a form and placing it in my db as so:

All of the text fields and one checkbox called enotify are needed for my WebRegister table. But, all Checkbox selections starting with the value "cksub" and <> "" will be sent to another table. (Note: the checkboxes were generated dynamically and there may be more than one set of checkboxes on the page because user needs to be able to select one or all of them per set) Anyway, my code is as follows:

<%
''Grab variables from the querystring and remove any apostrophes
FormCompany=Req uest.Form("txtC ompany")
strCompany=Repl ace(FormCompany , "''", "")

FormAddress=Req uest.Form("txtA ddress")
strAddress=Repl ace(FormAddress , "''", "")

FormCity=Reques t.Form("txtCity ")
strCity=Replace (FormCity, "''", "")

strState=Reques t.Form("txtStat e")
strZip=Request. Form("txtZip")
strPhone=Reques t.Form("txtPhon e")
strFax=Request. Form("txtFax")

FormWebsite=Req uest.Form("txtW ebsite")
strWebsite=Repl ace(FormWebsite , "''", "")

FormContact=Req uest.Form("txtC ontact")
strContact=Repl ace(FormContact , "''", "")

strCPhone=Reque st.Form("txtCPh one")

FormEmail=Reque st.Form("txtEma il")
strEmail=Replac e(FormEmail, "''", "")
If Request.Form("t xtnotify") = "-1" Then
FormNotify=Requ est.Form("txtno tify")
strNotify = "You have chosen to receive automatic e-mail notification "
strNotify = strNotify & "when goods and/or services you indicated, come up for bid."
Else
FormNotify = "0"
strNotify = "You will not be notified when goods and/or services you indicated "
strNotify = strNotify & "come up for bid"
End If

strhidDate=Requ est.Form("txtDa te")

''Create the statement to add a new record into the table "WebRegiste r".
''The first parenthesis set defines the field names as defined in the table and the second set
''of parenthesis places the values as assigned above (taken from the user input of the form
''on the Supplier_Reg.as p page) into the described fields of the table. The replace function
''[example: replace(strComp any, "''", "")] removes any apostrophes the user may have entered
''(which causes code problems) before inserting the data into the records. The replace
''function should be used whenever a user is free to key in data of their choosing.

''Create a RecordSet object
Set SupRs = Server.CreateOb ject("ADODB.Rec ordSet") ''Create Supplier/Contact Info Recordset
Set ComRs = Server.CreateOb ject("ADODB.Rec ordSet") ''Create Commodities Info Recordset

''Open the table
strProvider="Pr ovider=MSDASQL. 1;Persist Security Info=False;Data Source=Register "
SupRs.Open "WebRegiste r", strProvider, adOpenKeySet, adLockPessimist ic

''Add a new record to WebRegister Table
SupRs.AddNew
SupRs("Company_ Name") = strCompany
SupRs("St_Addre ss") = strAddress
SupRs("City") = strState
SupRs("Zip") = strZip
SupRs("Phone_Nu m") = strPhone
SupRs("Fax_Num" ) = strFax
SupRs("Web_Site ") = strWebsite
SupRs("Contact_ Person") = strContact
SupRs("Contact_ Phone") = strCPhone
SupRs("Contact_ Email") = strEmail
SupRs("Respond_ Da") = strhidDate
SupRs("E_Notify ")= FormNotify

''Update the record
SupRs.Update

''Retrieve the Registration Identification Number
strRegisterID = Rs("Register_ID ")

''Close the recordset
SupRs.Close
Set SupRs = Nothing

ComRs.Open "WebCommodities ", strProvider, adOpenKeySet, adLockPessimist ic

''Add a new record(s) to WebCommodities Table
''Need RegisterID for each checkbox selected
for each objItem in request.Form()
if left(objItem,5) ="cksub" and request.Form(ob jItem) <> "" then
ComRs.AddNew
ComRs("Register _ID") = strRegisterID
ComRs("SubCateg ory") = request.form(ob jItem)
ComRs.Update
next

''Close the recordset
ComRs.Close
Set ComRs = Nothing
%>

As far as my second issue is concerned, I''m not real confident that the For...Next loop to add the record(s) to the WebCommodities table is going to do the trick. There is other code on the page, but I believe its immaterial to my issues. I''d really appreciate any help on this!!

-----------------------------
This message is posted by http://Asp.ForumsZone.com

Jul 19 '05 #1
0 2789

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

Similar topics

11
8765
by: Jim | last post by:
Hi, I keep getting form results emailed to me that would indicate a form from my web site is getting submitted with all fields blank or empty, but my code should preventing users from proceeding if they left any field blank. My guess is that someone is trying to hack the site using the form to gain entry or run commands -- I don't really know since I'm not a hacker. I just know that forms are often susceptible to these kinds of...
13
2411
by: | last post by:
I have an Access database used to track donor pledges. In it, there is a table that contains three fields for each donor: Gift_Amount, Gift_Per_Year, and Matching_Gift_Ratio. The following formula would calculate the total pledge amount for each donor: (Gift_Amount * Gift_Per_Year) * (Matching_Gift_Ratio + 1). A total Pledge for all donors would just sum up the calculated values.
3
5626
by: Jake | last post by:
I am currently trying to create my own Point Of Sale software for my retail store. I wrote the program with the UPC field as Long integer. When I started to add the products by UPC code, I got a data mismatch error. I realized UPC codes are 12 digits, sometimes more and sometimes less. This falls out of the Long integer field type. I then changed my type on all UPC fields in all of the tables containing this field to a text data type. ...
1
1243
by: Mark | last post by:
I'm having a problem updating recordsin an Access DB table. I can update other tables in this db with no problem, and I can dreate new record in all of the tables (including this one.)> But I can't seem to update it. I keep getting this error: System.Data.OleDb.OleDbException: Data type mismatch in criteria expression from this line:
5
2046
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated one row, all of them were updated so i immediatelly figured out that i have to include the id of every entry in the update statement. This is where the problem is raised. My database is an Access database. The table i am updating contains a Date...
19
8390
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without FOR UPDATE, it is fine and no error. I also tried Set objRs = objConn.Execute("SELECT * FROM EMP UPDATE OF EMPNO"), but it still couldn't help. any ideas? I tried to search in the web but couldn't find similar
34
3859
by: clinttoris | last post by:
Hello Experts, I have been told to post this in the Javascript forum as I want to do this client side just before my form gets submitted. Once the user clicks the submit button a javascript function needs to run and validate all the checkboxes on my form and make sure none of them are unchecked. I suck at Javascript and my problem is 2fold. I have the following code that constructs the checkbox response.write "<input type=checkbox...
2
9023
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application. -------------------------------------------------------------------------------- Data type mismatch in criteria expression.
5
2083
by: kashif73 | last post by:
I have an application which updates record from my excel sheet into the MS SQL server DB. Thefirst line of my excel sheet has the column names of my database table. The problem arises with DATE column in my DB table. while updating I always get this error: "Microsoft VBScript runtime error '800a000d' Type mismatch: 'FormatDateTime' ". . Following is the code of ASP file, which looks OK to me though. IS it essential that in my excel...
0
9990
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11250
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10476
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9655
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7183
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6073
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4697
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4292
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3299
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.