473,749 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3120
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.publi c.dotnet.framew ork.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_IDENTIT Y 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**********@Y AHOO.COM> wrote in message
news:2E******** *************** ***********@mic rosoft.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_IDENTIT Y 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@_lunc hmeat_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_IDENTIT Y 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
2711
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 insert a row and give it the first available number? For example ID 1, 2, 4, 5, 6
2
8288
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 B
5
4552
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 field as the primary key of the table. If you are thinking of hiring an Access programmer or consultant ask
6
3816
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 taken from the part name (BrandA 300 4 Bladed : B3004B). The production number is a 4 or 5 digits number with first figure(s) indicating category (BrandA 300 4 Bladed: BrandA is category 1000. This Product would be 1003 if it was the third...
0
1561
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 objects offer a convenient way of working with database fields. For instance, if a database table contains a "quantity" column, then, in the program, you will use expressions like "row.quantity". This is more comfortable then writing something as...
13
4728
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 i type in the details. I have just moved over to mysql server with access as the front end. I have setup the sql tables with the customer number as autonumber. When i go into the form and add a new customer it does not generate the
0
1648
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 1 1234 789 2 1234 567 1 1234 345 1 I would like sale_no auto generated based on resv and locn, without using a trigger. Is this possible?
2
2521
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” “081-2008-00002” “081-2008-00003” and so on. The first 3 characters of those numbers are pulled in from one of the field, namely “Building #”. The second set of 4 digit numbers are nothing but the current year which gets pulled from another field namely...
9
2261
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, Assets, Comapnay, AssetCategorty, and AssetNumber. The number I would like to create would take data from Purchasing and Assets, then create a number that would be in this format: YY| company 3 letter abrivation | Asset Type | 3 digit auto generated...
0
8996
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, 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...
0
8832
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,...
1
9333
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,...
0
9254
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 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...
0
8256
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6800
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 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...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3319
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
2
2791
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.