473,394 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Rs.Addnew

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
3 15353
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Jan van Veldhuizen | last post by:
I have an application which is running fine with MS SqlServer, but it should be working with Oracle as weel. At a lot of places we rely upon the ADO Recordset to return incremented identity...
2
by: Tim Marshall | last post by:
ODBC situation, Access 97, here is the code and I've marked where Access coughs up. The Access error message is 3027, can't update, database is read only. The Oracle table in question has a...
1
by: Jon Trelfa | last post by:
I have been fighting with this script for several days and I'm finally at the end of my rope. Here's the scenario: -I have to add an entry into 1 table, called "calendar" -I must retrieve the...
6
by: Aaron Smith | last post by:
I have a form, oddly enough the same one with the expression column that is giving me a headache, and on this form I have a dataset that has a couple of tables in it that are related. If I do a...
2
by: guy | last post by:
if i use Generics.AddNew how do I pass an object to the items constructor? I have a set of class all inheriting from a base class, all requiring one parameter on their constructor - the data...
2
by: pillmill | last post by:
I replaced AddNew statments with INSERT INTO, but am unable to write to the same tables. Foreign keys violations are the main errors. Why are these occuring ? Before: set rs3=...
8
by: MLH | last post by:
Here's a snippet from A97 HELP on AddNew... The record that was current before you used AddNew remains current. If you want to make the new record current, you can set the Bookmark property to...
5
by: amey.gupte | last post by:
Hi, I am using the AddNew function in VBA to populate my access table from data in excel. The following is the piece of code: With WriteRS .AddNew !column_Names(0) = "acctNo" !B = "CoName"...
1
by: teenagelcruise | last post by:
hi, i have a problem with my code which is i cannot update and addnew data into the database but i can delete the data.plz give me an idea.this is my code that i wrote. <html> <head> <meta...
0
nev
by: nev | last post by:
Have any of you encountered this? And how did you correct it? bs.addnew() automatically moves the position to the new record. But mine doesn't. I have 3 bindingsources in my program, all...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.