473,503 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enteprise Library Data Access @@Identity

Hello all,

I have a need to use "select @@identity" to get the auto id on the row
that I just inserted. But for some reason, I always get back 0. I used
MS Access. Please advice.

Database InvestmentsDb = DatabaseFactory.CreateDatabase( "Investments"
);
using (IDbConnection connection = InvestmentsDb.GetConnection())
{
connection.Open();
IDbTransaction transaction = connection.BeginTransaction();
try{

DBCommandWrapper Proc_Login_Insert =
InvestmentsDb.GetStoredProcCommandWrapper(this.pro c_Logins_Insert); Proc_Login_Insert.AddInParameter("@UserName",
DbType.String,
this.userName); Proc_Login_Insert.AddInParameter("@Password",
DbType.String,
this.password); Proc_Login_Insert.AddInParameter("@Email",
DbType.String, this.email);
Proc_Login_Insert.AddInParameter("@RoleType", DbType.String,
"investor");
InvestmentsDb.ExecuteNonQuery(Proc_Login_Insert, transaction);

String id = "";
id =
Convert.ToString(InvestmentsDb.ExecuteScalar(Comma ndType.Text,"Select
@@Identity"));
log.Debug("Id is:"+id);
.....
....
....

Nov 19 '05 #1
2 906
never mind. my ExecuteScale wasn't part of the transaction and i added
it in, it works

Nov 19 '05 #2

forgive my ignorance, I am not an Access guru...however, I have only
used @@Identity in store procs right after I run the insert
statement...also, "Select @@Identiy" <-- how does it know which table
your talking about?

Anyway, why couldn't you run a select statement (after your insert
statement) like "Select top 1 idColumn from tbl order by idColumn desc"
(once again, I don't know if Access has a "TOP" keyword...)

Sorry I couldn't be more help...
--
rviray
------------------------------------------------------------------------
rviray's Profile: http://www.msusenet.com/member.php?userid=4211
View this thread: http://www.msusenet.com/t-1871084818

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5362
by: sedefo | last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i was researching how i can write a database independent data access layer. In my company we already use Data Access...
0
2213
by: ad | last post by:
I have used Data Application Access Block2 in my web application. Now I download the Library Data Access Application Block. and read the document. May be I am stupid, I can't migrate it to...
4
2857
by: FyinsFlip | last post by:
Microsoft Data Access Blocks (SqlHelper) you can do an insert and get the new row ID without using a stored procedure? DataMembers.Car_IDObject = SqlHelper.ExecuteScalar( _connectionString ,...
0
1143
by: Arjen | last post by:
Hi, I'm using the data access code block from the enterprise library inside an asp.net 2.0 webapplication. This application also uses the MembershipProvider. This one is using a...
2
2370
by: asad | last post by:
hello, how ru all pls tell me how can i create DAL and how can i use it in my ASP.NET pages thanks
0
1105
by: Tim | last post by:
I am having the exact same problem as below. Has anyone found the solution for this? I believe the solutions lies somewhere in here:...
3
2901
by: SAL | last post by:
Hi, I have Microsoft Enterprise Library 2005 installed on my local system. I'm developing in C# using Visual Studio 2003 IDE with framework 1.1. I am automating a process that will use a DLL...
11
1589
by: sanders_mike_newsgroups | last post by:
Hi I have a web app that needs to be able to use either SQL Server or MS Access - depending upon the installation. I want to avoid having unnessesary amounts of code (eg: dim x as...
3
1276
by: kbutterly | last post by:
Good morning, I have seen two different types of data access layers and I am wondering which, if either, is considered best practice, or if one is better suited to certain situations than the...
0
7199
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
7074
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...
0
7322
jinu1996
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...
1
6982
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...
0
7451
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...
1
5000
isladogs
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...
0
3161
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...
0
1501
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 ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.