Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: New to ASP - Need some quick help


Message #1 by "Sandi Williams" <sandi-williams@c...> on Wed, 20 Mar 2002 18:51:13
I am trying to write a new record to a database and am having trouble.  I 
can connect to and read the data without any difficulty. 

	Dim objConn, objRS, sSQL
	Set objConn = Server.CreateObject("ADODB.Connection")
	objConn.ConnectionString ="DSN=MyDB"
	objConn.Open
	Set objRS = Server.CreateObject("ADODB.Recordset")
	sSQL = "Select * from MyList"
	objRS.Open sSQL, objConn
	Do While Not objRS.EOF
		Response.Write "Data = " & objRS("DataField")
		objRS.MoveNext
	Loop

But when I try to open the recordset to add a new record:

	Dim objConn, objRS
	Set objConn = Server.CreateObject("ADODB.Connection")
	objConn.ConnectionString ="DSN=MyDB"
	objConn.Open
	Set objRS = Server.CreateObject("ADODB.Recordset")
	objRS.Open "MyList", objConn, , ,
        objRS.AddNew

I get the following error:
   ADODB.Recordset error '800a0cb3' 
   Object or provider is not capable of performing requested operation. 

Someone please help!!
Message #2 by Mark Eckeard <meckeard2000@y...> on Wed, 20 Mar 2002 10:59:08 -0800 (PST)
Sandi,

I would recommend NOT adding a record via the
recordset.  Insert the record straight into the DB.

Mark
--- Sandi Williams <sandi-williams@c...> wrote:
> I am trying to write a new record to a database and
> am having trouble.  I 
> can connect to and read the data without any
> difficulty. 
> 
> 	Dim objConn, objRS, sSQL
> 	Set objConn 
> Server.CreateObject("ADODB.Connection")
> 	objConn.ConnectionString ="DSN=MyDB"
> 	objConn.Open
> 	Set objRS = Server.CreateObject("ADODB.Recordset")
> 	sSQL = "Select * from MyList"
> 	objRS.Open sSQL, objConn
> 	Do While Not objRS.EOF
> 		Response.Write "Data = " & objRS("DataField")
> 		objRS.MoveNext
> 	Loop
> 
> But when I try to open the recordset to add a new
> record:
> 
> 	Dim objConn, objRS
> 	Set objConn 
> Server.CreateObject("ADODB.Connection")
> 	objConn.ConnectionString ="DSN=MyDB"
> 	objConn.Open
> 	Set objRS = Server.CreateObject("ADODB.Recordset")
> 	objRS.Open "MyList", objConn, , ,
>         objRS.AddNew
> 
> I get the following error:
>    ADODB.Recordset error '800a0cb3' 
>    Object or provider is not capable of performing
> requested operation. 
> 
> Someone please help!!


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/
Message #3 by Nikos <pappas@c...> on Wed, 20 Mar 2002 21:03:11 +0200
You dont need this to add a new record
just Insert it without creating a recordset only the connection object you

need and the sql statement.
use an SQLString
INSERT INTO MYTABLE (FIELD1,FIELD2,ETC..) VALUES ('VALUE1','VALUE2',ETC..)
objConn.execute SQLString

At 08:51 =EC=EC 20/3/2002, you wrote:
>I am trying to write a new record to a database and am having trouble.  I
>can connect to and read the data without any difficulty.
>
>         Dim objConn, objRS, sSQL
>         Set objConn =3D Server.CreateObject("ADODB.Connection")
>         objConn.ConnectionString =3D"DSN=3DMyDB"
>         objConn.Open
>         Set objRS =3D Server.CreateObject("ADODB.Recordset")
>         sSQL =3D "Select * from MyList"
>         objRS.Open sSQL, objConn
>         Do While Not objRS.EOF
>                 Response.Write "Data =3D " & objRS("DataField")
>                 objRS.MoveNext
>         Loop
>
>But when I try to open the recordset to add a new record:
>
>         Dim objConn, objRS
>         Set objConn =3D Server.CreateObject("ADODB.Connection")
>         objConn.ConnectionString =3D"DSN=3DMyDB"
>         objConn.Open
>         Set objRS =3D Server.CreateObject("ADODB.Recordset")
>         objRS.Open "MyList", objConn, , ,
>         objRS.AddNew
>
>I get the following error:
>    ADODB.Recordset error '800a0cb3'
>    Object or provider is not capable of performing requested operation.
>
>Someone please help!!

Message #4 by "Ciro Iodice" <ciro_iodice@h...> on Thu, 21 Mar 2002 13:21:17 +0100
Hello.
You said "objRS.Open "MyList", objConn, , ," as your recordset statement.
Be sure your default cursors allow updating just created recordset.
Take a try with "objRS.Open "MyList", objConn, 3,2  " (Dynamic recordset and
optimistic lock).
Hope it will help.

Ciao

Ciro Iodice



----- Original Message -----
From: "Sandi Williams" <sandi-williams@c...>
To: "ASP Databases" <asp_databases@p...>
Sent: Wednesday, March 20, 2002 6:51 PM
Subject: [asp_databases] New to ASP - Need some quick help


> I am trying to write a new record to a database and am having trouble.  I
> can connect to and read the data without any difficulty.
>
> Dim objConn, objRS, sSQL
> Set objConn = Server.CreateObject("ADODB.Connection")
> objConn.ConnectionString ="DSN=MyDB"
> objConn.Open
> Set objRS = Server.CreateObject("ADODB.Recordset")
> sSQL = "Select * from MyList"
> objRS.Open sSQL, objConn
> Do While Not objRS.EOF
> Response.Write "Data = " & objRS("DataField")
> objRS.MoveNext
> Loop
>
> But when I try to open the recordset to add a new record:
>
> Dim objConn, objRS
> Set objConn = Server.CreateObject("ADODB.Connection")
> objConn.ConnectionString ="DSN=MyDB"
> objConn.Open
> Set objRS = Server.CreateObject("ADODB.Recordset")
> objRS.Open "MyList", objConn, , ,
>         objRS.AddNew
>
> I get the following error:
>    ADODB.Recordset error '800a0cb3'
>    Object or provider is not capable of performing requested operation.
>
> Someone please help!!
>
Message #5 by "Sandi Williams" <Sandi-williams@c...> on Thu, 21 Mar 2002 16:46:00
Thanks, Ciro.  That was the problem.  I appreciate the help.

> Hello.
You said "objRS.Open "MyList", objConn, , ," as your recordset statement.
Be sure your default cursors allow updating just created recordset.
Take a try with "objRS.Open "MyList", objConn, 3,2  " (Dynamic recordset 
and
optimistic lock).
Hope it will help.

Ciao

Ciro Iodice



----- Original Message -----
From: "Sandi Williams" <sandi-williams@c...>
To: "ASP Databases" <asp_databases@p...>
Sent: Wednesday, March 20, 2002 6:51 PM
Subject: [asp_databases] New to ASP - Need some quick help


> I am trying to write a new record to a database and am having trouble.  I
> can connect to and read the data without any difficulty.
>
> Dim objConn, objRS, sSQL
> Set objConn = Server.CreateObject("ADODB.Connection")
> objConn.ConnectionString ="DSN=MyDB"
> objConn.Open
> Set objRS = Server.CreateObject("ADODB.Recordset")
> sSQL = "Select * from MyList"
> objRS.Open sSQL, objConn
> Do While Not objRS.EOF
> Response.Write "Data = " & objRS("DataField")
> objRS.MoveNext
> Loop
>
> But when I try to open the recordset to add a new record:
>
> Dim objConn, objRS
> Set objConn = Server.CreateObject("ADODB.Connection")
> objConn.ConnectionString ="DSN=MyDB"
> objConn.Open
> Set objRS = Server.CreateObject("ADODB.Recordset")
> objRS.Open "MyList", objConn, , ,
>         objRS.AddNew
>
> I get the following error:
>    ADODB.Recordset error '800a0cb3'
>    Object or provider is not capable of performing requested operation.
>
> Someone please help!!
>

  Return to Index