Re: Addnew method failed on empty recordset
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Wed, 28 Nov 2007 09:06:57 -0500
Max wrote:
Hi i am having table Data with field name code, Data Table is empty,
when i tried to Addnew, Update method through ADO it fails it is not
showing any records ?
my syntex is
dim i as integer
cn.open path
rs.open "Data",cn,adOpenDynamic, adLockBatchOptimistic
thanx
for i=1 to 100
rs.addnew
rs!code= i
next
adOpenDynamic and adLockBatchOptimistic are mutually exclusive. You must
also have "on error resume next" somewhere because that open statement
should be throwing an error. You did not specify adCmtTable and "Data"
does not contain any sql keywords, so an error should have been raised.
Instead of using a recordset, do this instead:
dim i as integer
dim cmd as adodb.command
dim sql as string
sql = "insert into Data ([code]) values (?)"
cn.open path
set cmd = new adodb.command
with cmd
.commandtext = sql
.commandtype = adCmdText
set .activeconnection = cn
end with
for i=1 to 100
cmd.execute ,array(i),adExecuteNoRecords
next i
cn.close
If you must use a recordset for some reason, I need to question why you
are trying to use adLockBatchOptimistic - are you desiring to disconnect
the recordset?
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
.
- Follow-Ups:
- Re: Addnew method failed on empty recordset
- From: Ralph
- Re: Addnew method failed on empty recordset
- Prev by Date: Re: Addnew method failed on empty recordset
- Next by Date: Re: Addnew method failed on empty recordset
- Previous by thread: Re: Addnew method failed on empty recordset
- Next by thread: Re: Addnew method failed on empty recordset
- Index(es):
Relevant Pages
|
|