Re: How To Return Record Number From AddNew
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Mon, 27 Aug 2007 11:23:48 -0400
Jeff Gaines wrote:
On 27/08/2007 in message <ecOJhlJ6HHA.5160@xxxxxxxxxxxxxxxxxxxx> Bob
Barrows [MVP] wrote:
My pesonal recommendation: don't use a recordset for data
maintenance. Instead, use SQL DML (INSERT, UPDATE and DELETE)
statements, wither encapsulated in saved parameter queries (stored
procedures) or parameterized with parameter markers. This will allow
you to execute the SELECT @@identity statement to retrieve the new
autonumber.
Many thanks, Bob :-)
The links are particularly helpful, and they led to other links and
so on...
I am struggling to find which version of MSJet I have. There are
jet500.dll, msjet35.dll and msjet40.dll on the system. I use Access
97 and the connections string is:
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
strConnection += m_DBPath;
strConnection += ";";
Since this works then presumably I have version 4?
No, but it's backward-compatible in my experience. I have read some
admonitions here and there against using the 4.0 driver against an A97
(Jet 3.51) database, but I have never run into any issues.
I am trying to add "SELECT @@IDENTITY" to the connection string but it
falls over with that.
It cannot be added to the connection string. You have to use it as the
source of a recordset: it's a SQL Select statement.
My real problem at the moment is:
If I use adRS("0") I get the error 'adRS' is a 'variable' but is used
like a 'method'
How did you try to use it?
Is the name of the field "0"? You never showed us the select statement
used to open the recordset, so I have no idea what the names of the
fields in the recordset are. Of course, using the field names is
inefficient compared to using the ordinal positions of the fields to
refer to them. I don't do C# so you will need to translate this, but If
you are trying to see the value of the first field in the recordset you
would do this:
valuoffirstfield=adRS(0).value
If I use adRS["RecordNumber"] I get the error Cannot apply indexing
with [] to an expression of type 'ADODB.Recordset'
What is the name of your autonumber field?
All the examples I have found are VB/VBScript, usually you can replace
round brackets with square ones for C but apparently not here!
Better to ask about this in a C# newsgroup.
PS. Why are you using classic ADO in a .Net application? You should be
using ADO.Net. You should post ADO.Net questions to this group:
microsoft.public.dotnet.framework.adonet
--
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: How To Return Record Number From AddNew
- From: Jeff Gaines
- Re: How To Return Record Number From AddNew
- From: Ralph
- Re: How To Return Record Number From AddNew
- References:
- How To Return Record Number From AddNew
- From: Jeff Gaines
- Re: How To Return Record Number From AddNew
- From: Bob Barrows [MVP]
- Re: How To Return Record Number From AddNew
- From: Jeff Gaines
- How To Return Record Number From AddNew
- Prev by Date: Re: How To Return Record Number From AddNew
- Next by Date: Re: How To Return Record Number From AddNew
- Previous by thread: Re: How To Return Record Number From AddNew
- Next by thread: Re: How To Return Record Number From AddNew
- Index(es):
Relevant Pages
|
|