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!

ASP & MS Access - SQL Error??

Status
Not open for further replies.

scripter50

IS-IT--Management
Dec 9, 2002
35
US
I have a website written in ASP with an Access db. I have an INSERT on a page that does not produce any ASP error (err.description), but produces a browser error saying "error with sql insert statement". The insert is completing even though the error is displayed??? Any ideas out there?

thanks in advance
 
sql_insert = "insert into tblPets (intPetKey, strPetName, intPetType, strPetBreed, strPetGender, strPetMeds, " & _
" strPetBirthdate, strPetQuarters, strHealth, strVaccinations, strExercise, strBehaviorAdult, strBehaviorChild, strBehaviorAnimal, " & _
" strVetName, strVetAddress, strVetPhone, strPetNotes, intXrefCust, intPetNumber, strLastModified) " & _
" values (" & nNewPetKey & "," & sPetName & "," & nPetType & "," & sPetBreed & "," & sPetGender & "," & _
sPetMeds & "," & sPetBirthdate & "," & sPetQuarters & "," & sPetHealth & "," & sVaccinations & "," & sPetExercise & "," & _
sBehaviorAdult & "," & sBehaviorChild & "," & sBehaviorAnimal & "," & sVetName & "," & sVetAddress & "," & _
sVetPhone & "," & sPetNote & "," & nCustKey & "," & nNewPetCount & "," & sDateString & ")"

'response.write sql_insert
'response.end

objConn.execute sql_insert

if err.number <> 0 then
Response.write "Error with sql insert = " & err.description & "-" & sql_insert
end if
 
Most likely there is an [tt]On Error Resume Next[/tt] statement somewhere in the code near the top... and then some other unrelated error occurs but is ignored.

Try adding something like the following immediately before the code that you pasted above:[tt]
if err.number <> 0 then
Response.write "<br><br>Error #" & err.number
Response.write " --> " & err.description & "<br><br>" & vbCrLF
Response.End
end if
[/tt]

That should help find the previous error.

If that doesnt work try checking the errors collection of your ado connection object.
 
When I response.write the sql statement and copy it to access, it works just fine. that was the first thing I tested. I figured it that worked, then all is well, but I'll see if it's really an error before the sql statement is run.
 
Keep in mind that not all errors will whow up in the err object. The ADO Connection object has an errors collection that holds ADO Error objects when errors occur during db transactions.

I would suggest Response.Write'ing the SQL statement again and posting it here. Double check any fields that might be empty int your insert statement but aren't set to allow nulls in your db. Also double check that strings and dates in your insert have single quotes around them and so on.

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top