473,406 Members | 2,843 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,406 software developers and data experts.

RETIRIVAL OF AUTO GENERATED NUMBER

DEAR SIRS,

I AM DEVELOPING A SOFTWARE BY USING VB.NET AND SQLSERVER 2000 FOR A NETWORK ENVIRONMENT. I HAVE A BROBLEM THAT I HAVE A FIELD FOR PRIMERY KEY WHICH IS AUTO GENERATED. I NEED THAT WHEN THE FORM IS LOADED THE NEXT AUTO GENERATED NO SHOULD BE IN THE REQUIRED TEXTBOX. HOW TO GET THE NEXT NUMBER FROM SQLSERVER2000 TO TEXTBOX.

I WILL APPRICIAT YOUR COOPERATION.
MUSTAFA IRSHAD
Nov 20 '05 #1
4 3099
Cor
Hi Mustafa,

I think that you should make a Select sentence with an order clause in it
and use a datareader.

http://msdn.microsoft.com/library/de...datareader.asp

A better newsgroup to ask this question is
microsoft.public.dotnet.framework.adonet

But I hope this helps?

Cor

ps. A lot of people do not answer messages with uppercases, so if you are
able to avoid that I think that i better.

I AM DEVELOPING A SOFTWARE BY USING VB.NET AND SQLSERVER 2000 FOR A NETWORK ENVIRONMENT. I HAVE A BROBLEM THAT I HAVE A FIELD FOR PRIMERY KEY
WHICH IS AUTO GENERATED. I NEED THAT WHEN THE FORM IS LOADED THE NEXT AUTO
GENERATED NO SHOULD BE IN THE REQUIRED TEXTBOX. HOW TO GET THE NEXT NUMBER
FROM SQLSERVER2000 TO TEXTBOX.
I WILL APPRICIAT YOUR COOPERATION.

Nov 20 '05 #2
Mustafa,

The best way to do this is to use a stored procedure on the database that
when the procedure is finished doing its insert which generates the
auto-gen'd number for the primary key, use RETURN @@SCOPE_IDENTITY at the
end of your stored proc, and capture this as a return value in VB. Saves a
round trip to the DB server to go back and get the value using a large where
clause, and you don't have datareader overhead.

Aiax

"MUSTAFA IRSHAD" <MU**********@YAHOO.COM> wrote in message
news:2E**********************************@microsof t.com...
DEAR SIRS,

I AM DEVELOPING A SOFTWARE BY USING VB.NET AND SQLSERVER 2000 FOR A NETWORK ENVIRONMENT. I HAVE A BROBLEM THAT I HAVE A FIELD FOR PRIMERY KEY
WHICH IS AUTO GENERATED. I NEED THAT WHEN THE FORM IS LOADED THE NEXT AUTO
GENERATED NO SHOULD BE IN THE REQUIRED TEXTBOX. HOW TO GET THE NEXT NUMBER
FROM SQLSERVER2000 TO TEXTBOX.
I WILL APPRICIAT YOUR COOPERATION.
MUSTAFA IRSHAD

Nov 20 '05 #3
On Wed, 14 Jan 2004 07:17:08 -0600, aiax wrote:
auto-gen'd number for the primary key, use RETURN @@SCOPE_IDENTITY at the


I think when calling SCOPE_IDENTITY, you do not use the @@ on the front of
it. I was working with this yesterday and discovered that when return
SCOPE_IDENTITY you do it without the @@ in the front.

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #4
Chris,

You are absolutely right. It would be SCOPE_IDENTITY() or you can use
@@IDENTITY if scope is of no concern. Sometimes my brains mixes my
thoughts. :)

Aiax

"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:1g******************************@40tude.net.. .
On Wed, 14 Jan 2004 07:17:08 -0600, aiax wrote:
auto-gen'd number for the primary key, use RETURN @@SCOPE_IDENTITY at
the
I think when calling SCOPE_IDENTITY, you do not use the @@ on the front of
it. I was working with this yesterday and discovered that when return
SCOPE_IDENTITY you do it without the @@ in the front.

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Nov 20 '05 #5

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

Similar topics

4
by: Sims | last post by:
Hi, I have a table that give a unique ID to certain Articles. To give the ID i simply use the Auto count of the DB. But what happens when i delete a record? i am now missing an ID. How can i...
2
by: Laphan | last post by:
Hi All This is a strange request, but I just cannot fathom how to do it. In theory the requirement is very basic, but in practise its a noodle!! I have 10 team names like so: Team A Team...
5
by: Geoff Cayzer | last post by:
At http://www.blueclaw-db.com/tips_tricks.htm I came across a section which is included below and was hoping for some comment on the article. -------------- Almost never use this auto-number...
6
by: Sebastien | last post by:
Hi, I am building a products database, linking sales and production. Each part has a unique sales Stock Code and Production Number. The sales stock code is a combination of letters and numbers...
0
by: Viorel | last post by:
Working as a beginner with data objects in Visual Studio 2003 and C#, I use the "Generate Dataset" command in order to generate automatically the dataset objects based on data adapters. Generated...
13
by: S.Dickson | last post by:
I had an access database that i use as an ordering system. I have a form for entering customer details. When i add a new customer on the form the customer number is an auto number that appears when...
0
barbk
by: barbk | last post by:
Hey all, In DB2 v9 is it possible to have an auto generated number field within a primary key that is a combination of multiple fields? For example resv locn sale_no 1234 789...
2
by: Irving Guy | last post by:
Hi all, I’m trying to create a form with 15 fields that generates an auto number in one of those 15 fields. The auto generated number which should display like this – “081-2008-00001”...
9
zimes
by: zimes | last post by:
I am working with Microsoft Access 2003 from the Office XP pro suite. I have created several tables that have to do with Asset tracking along with purchasing. I have a table called Purchasing,...
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.