<html>
<head>
<title> database connectivity </title>
</head>
<body>

<H1> DATABASE CONNECTIVITY </H1>


<% 
   dim constr 
   constr= "provider=sqloledb;data source=1.234.5.678,1234;initial catalog = abcd; User Id=abcd; password=abcd"
   
   

   set conobj = server.createobject("ADODB.Connection")
   conobj.connectionstring = constr
   
   conobj.open
   
   
   set comobj = Server.CreateObject("ADODB.Command")
   comobj.CommandText = "test2"
   comobj.CommandType =  adCmdTable
   set rs1 = comobj.Execute 
%>
      
 
</body>
</html>

i am trying to show the recordset with the code..
the error i get is :
ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
line 24

Where am i going wrong ?

i did that......
its still the same error....

Try setting the activeconnection first:

set comm=Server.CreateObject("ADODB.Command")
comm.ActiveConnection=conn

thank's.......... it works now..
but do i really need the connection object in this case ??

thank's.......... it works now..
but do i really need the connection object in this case ??

The command object needs to know how to connect to your database. So yes, you need either a connection string or a connection object. I can't remember if a command object can use just the connection string or not.

If you just specify the connection string to your cmd object and it works, you can drop the connection object, yes.

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.