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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch

Status
Not open for further replies.

mortkc

MIS
Apr 23, 2001
84
US
I am trying to add (via ASP) a combination of letters and numbers to a "SerialNumber" field in an Access Table, and it returns a Type Mismatch. If I enter only numbers, the code works fine. It is failing on the following lines:

strItemID = CStr(Request("txtSN"))
ItemRS("ItemID") = strItemID

Any suggestions on what I am doing wrong would be greatly appreciated. Thanks!
 
My MSAccess field is set to text, but it is still returning an error.
 
Have you response.write the concatenated string to see how it looks
 
I just tried, and it looks fine. The number I entered was sf11, and when I do the response.write, it appears the same.
 
I tried adding it manually to the database and it worked without error. I only get an error when adding with ASP. Thanks.
 
Are you sure the error is coming back from Access? Could it be related to the CStr your doing on the previous line?

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
I would say the same. Using cStr() on a request seems usless. if you submitted the value to the colection through a form process it will be a string data type already.

_____________________________________________________________________
onpnt2.gif

 
The code now reads:

strItemID = Request("txtSN")
ItemRS("ItemID") = strItemID

I am still getting the type mismatch on the second line.
 
what exacetly are you doing here
strItemID = Request("txtSN")
ItemRS("ItemID") = strItemID

does this indicate you've initialized the ItemRS.AddNew method etc...

sense you're giving the value to the RS

_____________________________________________________________________
onpnt2.gif

 
for now, I have gotten around this error by removing the two lines. I am going to go about this from a different angle for now, due to a deadline. Thanks for all your help, and I will post a response once I have time to go back and find the error of my ways. Thanks again.
 
OK, now I have just confused the issue more.... Here is the new error:

You cannot add or change a record because a related record is required in table 'Items'.
/intranet/emarketpe/inc/process_addItems.asp, line 38

This is the code I am using:

strCategory = Request("CategoryID")
strName = Request("txtName")
strSN = Request("txtSN")
strDetails = Request("txtDetails")
strPicture = Request("selPix")
strEndTime = "11:59PM"
'strLocation = "300 Littleton"
strSeller = Request("txtSeller")


' Add items into the Auctions table

strStartBid = trim(Request("txtStartBid"))
strEndDate = trim(Request("txtEndDate"))
strBidStatus = trim(Request("chkBidStatus"))
strBidder="postmaster"
strSQL = "INSERT INTO Auctions(StartBid,Bidder,BidStatus,EndDate)Values(" & strStartBid & "," & "'" & strBidder &"'" & "," & strBidStatus & "," & "#" & strEndDate & "#)"

objConn.Execute strSQL

'Add Items into the Items Table

Set ItemRS = Server.Createobject("adodb.recordset")
ItemRS.Open "Items",objConn,3,3

ItemRS.addnew
ItemRS("SerialNumber") = strSN
ItemRS("ItemName") = strName
ItemRS("ItemDetails") = strDetails
ItemRS("CategoryID") = strCategory
ItemRS("Picture") = strPicture
ItemRS("Seller") = strSeller

ItemRS.Update
ItemRS.MoveLast


ItemRS.Close
set ItemRS = nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top