<html>
<head>
<title> database ado </title>
</head>

<body>
<%constr = "provider= sqloledb; data source = 6.123.3.183,1234; initial catalog=dbase;User id=scot; password=pwd1"%> 

<%set conpubs= server.createobject("ADODB.Connection")
conpubs.connectionstring= constr
conpubs.open%>

<%Dim rstest
Set rstest = Server.CreateObject("ADODB.Recordset")
rstest.Open "test", constr, adOpenDynamic, adLockOptimistic, adCommandTableDirect
rstest.addnew.fields("name")="three"
rstest.update%>
<%while not rstest.EOF
 
 Response.Write rstest("name") & "<br>"
 rstest.movenext
 
Wend%>

</body>
</html>

the error i get is :
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
line 15..

plz help...
thank's...

Recommended Answers

All 9 Replies

somebody please help....have to move forward.. :(

rstest.Open "test", constr, adOpenDynamic, adLockOptimistic, adCommandTableDirect

aashishn86, you cannot use named parameters without first declaring them.

Try

rstest.Open "test", constr, 2, 3, 512

See here for more numeric values.

Alternatively, you can declare the variables first. like so:

DIM adOpenDynamic, adLockOptimistic, adCommandTableDirect
adOpenDynamic = 2
adLockOptimistic = 3
adCommandTableDirect = 512

Then you can use the named arguments in your open stmt.

hey thank's..... i tried that too...
but it still gives the same error...

hey thank's..... i tried that too...
but it still gives the same error...

I usually just use:

rstest.Open "tablename", constr, 2, 2

Can you please verify the exact line and highlight it? I havn't see the addnew method used like that before, not saying it won't work, but just to make sure.

commented: you were right... it doesn't work this way :) +1

thank's......
i'll do that tomorrow and post back..
no access to the server at the moment...

<% @Language ="VBscript" %>
<html>
<body>

<% 
   DIM adOpenDynamic, adLockOptimistic,    adCommandTableDirect
   adOpenDynamic = 2
   adLockOptimistic = 3
   adCommandTableDirect = 512   

   constr="provider=sqloledb;data source=1.234.5.678,1234;initial catalog = abcd; User Id=abcde; password=abcde"
   
   Set RSObj = Server.CreateObject("ADODB.RecordSet")
   RSObj.Open "test2",constr,2,3,512
   
   RsObj.AddNew.Fields("fname")="aashish"
   RsObj.AddNew.Fields("lname")= "n"
   RsObj.Update
 %>

</html>
</body>

The error i know get is :
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: '[undefined]'
/aashish/db8.asp, line 16

well, the problem was
i was suppose to write it as

RsObj.AddNew
RsObj.Fields("fname")="aashish"
RsObj.Fields("lname")="n"
RsObj.Update

Thank's agrothe , for all the help...............

well, the problem was
i was suppose to write it as

RsObj.AddNew
RsObj.Fields("fname")="aashish"
RsObj.Fields("lname")="n"
RsObj.Update

Thank's agrothe , for all the help...............

You're welcome! Your previous use of addnew was suspect to say the least! I'm glad your up and running again.

I would now suggest you start using parametrized queries. The method you are using now is very susceptible to SQL Injection Attacks, which I've experience first hand :) .

The provided link is from 4guysfromrolla website and is an excellent way to update your database (very simple) and provides much greater security.

Cheers.

PS: please mark the thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.