Hello,
i am wondering if there is a simple way to insert a new record into an MS
Access db and read out the newly created auto-ID field. Using ASP this was
rather simple, but in ASP.NET (VB) it seems to have become rather
complex????
cheers, Olaf 4 1948
See the following KB article:
HOW TO: Retrieve the Identity Value While Inserting Records into
Access Database By Using Visual Basic .NET http://support.microsoft.com/default...b;en-us;815629
--Mary
On Mon, 21 Feb 2005 18:14:47 +0100, "olafmol" <ol**@expansion s.nl>
wrote: Hello,
i am wondering if there is a simple way to insert a new record into an MS Access db and read out the newly created auto-ID field. Using ASP this was rather simple, but in ASP.NET (VB) it seems to have become rather complex????
cheers, Olaf
Hi Olaf,
To insert a record
In ADO:
Dim conn As New ADODB.Connectio n
conn.Open connextString
conn.Execute insertSql
conn.Close
Set conn = Nothing
In ADO.NET
Dim conn As New OleDbConnection (connectionStri ng)
conn.Open()
Dim command As OleDbCommand = conn.CreateComm and()
command.Command Type = CommandType.Tex t
command.Command Text = insertSql
command.Execute NonQuery()
conn.Close()
So what's big difference?
HTH
Elton Wang el********@hotm ail.com -----Original Message----- Hello,
i am wondering if there is a simple way to insert a new
record into an MSAccess db and read out the newly created auto-ID field.
Using ASP this wasrather simple, but in ASP.NET (VB) it seems to have
become rathercomplex????
cheers, Olaf
.
Hello Elton,
not much, but where do you read the autonumber value of the newly inserted
record?
cheers, Olaf
Elton Wang <an*******@disc ussions.microso ft.com> wrote in message
news:0a******** *************** *****@phx.gbl.. . Hi Olaf,
To insert a record
In ADO: Dim conn As New ADODB.Connectio n conn.Open connextString conn.Execute insertSql conn.Close Set conn = Nothing
In ADO.NET Dim conn As New OleDbConnection (connectionStri ng) conn.Open() Dim command As OleDbCommand = conn.CreateComm and() command.Command Type = CommandType.Tex t command.Command Text = insertSql command.Execute NonQuery() conn.Close()
So what's big difference?
HTH
Elton Wang el********@hotm ail.com
-----Original Message----- Hello,
i am wondering if there is a simple way to insert a new record into an MSAccess db and read out the newly created auto-ID field. Using ASP this wasrather simple, but in ASP.NET (VB) it seems to have become rathercomplex????
cheers, Olaf
.
You can try
After
command.Execute NonQuery()
command.Command Text = "SELECT @@IDENTITY"
Dim obj As Object
Dim autoNum As Integer
obj = command.Execute Scalar()
If not obj Is Nothing Then
autoNum = Integer.Parse(o bj)
End If
HTH
Elton -----Original Message----- Hello Elton,
not much, but where do you read the autonumber value of
the newly insertedrecord?
cheers, Olaf
Elton Wang <an*******@disc ussions.microso ft.com> wrote in
messagenews:0a******* *************** ******@phx.gbl. .. Hi Olaf,
To insert a record
In ADO: Dim conn As New ADODB.Connectio n conn.Open connextString conn.Execute insertSql conn.Close Set conn = Nothing
In ADO.NET Dim conn As New OleDbConnection (connectionStri ng) conn.Open() Dim command As OleDbCommand = conn.CreateComm and() command.Command Type = CommandType.Tex t command.Command Text = insertSql command.Execute NonQuery() conn.Close()
So what's big difference?
HTH
Elton Wang el********@hotm ail.com
>-----Original Message----- >Hello, > >i am wondering if there is a simple way to insert a new record into an MS >Access db and read out the newly created auto-ID field. Using ASP this was >rather simple, but in ASP.NET (VB) it seems to have become rather >complex???? > >cheers, Olaf > > >. >
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: olafmol |
last post by:
Hello,
i am wondering if there is a simple way to insert a new record into an MS
Access db and read out the newly created auto-ID field. Using ASP this was
rather simple, but in ASP.NET (VB) it seems to have become rather
complex????
cheers, Olaf
|
by: Pete |
last post by:
Does anyone have a simple html vbscript or other type of snippet they
can share that appends a record to a access database via ADO or DAO?
I would like to allow users that don't have Microsoft Access a way of
adding records to a access database from a simple web page. I don't
want to have to setup ODBC or anything like that I just want to put
the web page on the network for anyone to access. Most of the users
would use the local access...
|
by: Bri |
last post by:
Greetings,
I'm having a very strange problem in an AC97 MDB with ODBC Linked tables
to SQL Server 7. The table has an Identity field and a Timestamp field.
The problem is that when a new record is entered, either from a form or
from the table view of the table, when the record gets saved it
immediately displays #DELETED# in all of the fields. However, if I close
the form or table view and reopen the record has in fact been inserted.
The...
|
by: Carl |
last post by:
Hi,
I hope someone can share some of their professional advice and help me out
with my embarissing problem concerning an Access INSERT query. I have never
attempted to create a table with one-to-one relationship but on this
occasion
I must keep username/password details within a seperate table.
Here's the basic specs and database schema:
-------------------------------------------
|
by: HS1 |
last post by:
Hello
I have a table in Access Database. This table has a AutoNumber field. I use
a DataGrid to show that table
When I insert a new record in for this table using a DataGrid, there is a
message that asks me to enter the value for this AutoNumber field. Why I
have to do that?
Could you please help
| |
by: Deano |
last post by:
Problem is that there are lots and lots of fields in an employee record. I
specify a form control as the criterion for one of those fields which is the
value of the primary key for that record. The idea is to copy the current
record I am viewing in the form, to another table.
I want to simple execute a stored query but I get a run-time error 3061, too
few parameters. Expected 1. So even though I've specified the control
within the...
|
by: Materialised |
last post by:
Hi Folks,
Just a quickie, I am inserting some records (individually) into a SQL
Server Table. I am wondering how can I detect primary key violations on
this data which I am inserting into the table.
My Insert code is as follows (VB.Net):
Public Function InsertNewUser(ByVal _ConnString As String, ByVal
UserAccess As UserAccess.Access) As Integer
|
by: Mark Olbert |
last post by:
I am struggling with trying to retrieve the value of an autoincrement identity field after a DetailsView Insert operation. The
DetailsView is bound to an SqlDataSource control.
So far as I can tell, nowhere in the arguments for either the Inserted event for the DetailsView or the Inserted event for the
SqlDataSource control is the value stored. Adding a dummy bound column for the identity field to the DetailsView doesn't work,
either.
...
|
by: MLH |
last post by:
Suppose, in a multi-user environment, you
have append query SQL in a VBA procedure
that looks like INSERT INTO MyTable...
and the next line reads MyVar=DMax("","MyTable...
You can never be certain that MyVar will be
set to the key-field value that was created
when the Append query ran. Now, there are
other ways to do it - I know - that will ensure
you 'nab' the correct record. But I was wondering
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |