By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,253 Members | 1,676 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,253 IT Pros & Developers. It's quick & easy.

Rs.Addnew

P: n/a
I want to avoid INSERT INTO command. This command creates too hassle
for proper syntax.

How can I use
set rs = Server.CreateObject("ADODB.recordset")
rs.Open("temp", "", LockType.Optimistic)
rs.AddNew
rs.Fields("txt") = "test"
rs.Update
rs.Close
This code is not working. Also how can this be used to update a record.

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ka*****@humsay.com wrote:
I want to avoid INSERT INTO command. This command creates too hassle
for proper syntax.

How can I use
set rs = Server.CreateObject("ADODB.recordset")
rs.Open("temp", "", LockType.Optimistic)
rs.AddNew
rs.Fields("txt") = "test"
rs.Update
rs.Close
This code is not working. Also how can this be used to update a record.


I don't think "" is a valid connection to use.

--
This sig left intentionally blank
Nov 13 '05 #2

P: n/a
Dim cnxn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cnxn = CurrentProject.Connection
Set rs = New ADODB.Recordset
With rs
.Open "temp", cnxn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
.AddNew
.Fields("txt") = "test"
.Update
.Close
End With
Set rs = Nothing
However, are you sure you don't want to just write:

Dim cnxn As ADODB.Connection
Set cnxn = CurrentProject.Connection
cnxn.Execute "INSERT INTO temp (txt) VALUES ('test')"
Darryl Kerkeslager

<ka*****@humsay.com> wrote:
I want to avoid INSERT INTO command. This command creates too hassle
for proper syntax.

How can I use
set rs = Server.CreateObject("ADODB.recordset")
rs.Open("temp", "", LockType.Optimistic)
rs.AddNew
rs.Fields("txt") = "test"
rs.Update
rs.Close
This code is not working. Also how can this be used to update a record.

Nov 13 '05 #3

P: n/a
It's been pointed out that you were likely doing an ASP - and I missed that.

The principle is of course the same, just with the CreateObject, but if it's
an ASP related problem, perhaps you should re-post under that subject line.
However, I suspect that the main problem you experienced was with the
mal-formed Recordset Open method, as the CreateObject appears correct.
Darryl Kerkeslager
"Darryl Kerkeslager" <Ke*********@comcast.net> wrote:
Dim cnxn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cnxn = CurrentProject.Connection
Set rs = New ADODB.Recordset
With rs
.Open "temp", cnxn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
.AddNew
.Fields("txt") = "test"
.Update
.Close
End With
Set rs = Nothing
However, are you sure you don't want to just write:

Dim cnxn As ADODB.Connection
Set cnxn = CurrentProject.Connection
cnxn.Execute "INSERT INTO temp (txt) VALUES ('test')"
Darryl Kerkeslager

<ka*****@humsay.com> wrote:
I want to avoid INSERT INTO command. This command creates too hassle
for proper syntax.

How can I use
set rs = Server.CreateObject("ADODB.recordset")
rs.Open("temp", "", LockType.Optimistic)
rs.AddNew
rs.Fields("txt") = "test"
rs.Update
rs.Close
This code is not working. Also how can this be used to update a record.


Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.