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

ADDING RECORD TO SQL SERVER TABLE DOESN'T WORK

Status
Not open for further replies.

Coding

Programmer
Aug 13, 2000
25
0
0
CA
Does anyone know how to fix this bug which error message is showed below:

HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

-----------------------------------------------------------

Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/comprecord/save.asp, line 47

I am not able to add new record. The update works without any problem. The code for adding new record worked in MS Access, but it shows me error message with SQL Server.
I appreciate your help.

Coding
 
Hi
Can you post the code where you insert a record.

 
Is there a date field in the record you are trying to add? Access and SQL Server handle dates differently. In Access they are usually delimited by #'s, but SQL Server uses the single quote delimiter.
 
'This is comprecord.inc file of DSN connection for SQL
'Server:

<!-- #Include file=&quot;adovbs.inc&quot; -->
<%
Dim objConnect
set objConnect = Server.CreateObject(&quot;ADODB.Connection&quot;)
objConnect.Open &quot;DSN=companies&quot;, &quot;sa&quot;, &quot;&quot;

%>

'This is comprecord.inc file of ODBC driver for Access
'database:

<!-- #Include file=&quot;adovbs.inc&quot; -->
<%
Dim objConnect
set objConnect = Server.CreateObject(&quot;ADODB.Connection&quot;)
objConnect.Open &quot;Driver={Microsoft Access Driver
( *.mdb)}; DBQ=&quot; & server.mappath(&quot;comprecord1.mdb&quot;)

%>

'This is save.asp file

<!--include file=&quot;comprecord.inc&quot;-->
<%

Response.Buffer=true
Response.Clear

Function ConvertValue(ByVal xVal)

if isNull(xVal) or xVal = &quot;&quot; then
ConvertValue=0
elseif xVal = &quot;on&quot; then
ConvertValue=1
end if

End function

Dim strCompanyName, strCity, strProvince, strTelephone, strEmail, blnResumeSent, strContactPerson, strLastContactDate, strComment
strCompanyName=request(&quot;txtCompanyName&quot;)
strCity=request(&quot;txtCity&quot;)
strProvince=request(&quot;cboProvince&quot;)
strTelephone=request(&quot;txtTelephone&quot;)
strEmail=request(&quot;txtEmail&quot;)
blnResumeSent=ConvertValue(Request.Form(&quot;chkResumeSent&quot;))
strContactPerson=request(&quot;txtContactPerson&quot;)
strLastContactDate=request(&quot;txtLastContactDate&quot;)
strComment=request(&quot;txtComment&quot;)


Dim rsCompRecord
Dim strSQL
set rsCompRecord = server.CreateObject(&quot;adodb.recordset&quot;)
strSQL = &quot;select * from CompRecord&quot;
Error-> rsCompRecord.Open strSQL, objConnect, 2, 3


 
I forgot to mention that I get the same error message on the same line in the save.asp file with a code for Access database.Does that mean that both databases settings are OK and something is wrong with IIS settings or else?

Thank you for your help.
 
I am confused, in your first post you said you were not able to add a recorxd, but the code you are showing us is for selecting the records from a table...?

I would expect (if you are later attempting to do an AddNew) that it is possible your recordset is confuse since you have not specified whether it is opening a table, executing a query, executing a stored procedure, etc.

Try adding a 1 as the 5th argument (1 = adCmdText):
Code:
rsCompRecord.Open strSQL, objConnect, 2, 3, 1

Also, if your including the adovbs.inc file, I don't see why your using numeric constant values in your .Open rather than the actual constants (just curiousity really).

-Tarwn ________________________________________________
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top