Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #31  
Old May 5th, 2008, 03:58 PM
Wolffy's Avatar
Wolffy Wolffy is offline
Slaprentice of Wolves
Click here for more information.
 
Join Date: Aug 2007
Location: Mossville, IL
Posts: 1,015 Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 2 h 3 m 50 sec
Reputation Power: 329
Assuming you have ID defined as an Identity field:
Code:
INSERT <into first table>
SET @newId = @@IDENTITY
<more code>
INSERT userId, <more columns>
VALUES (@newId, <more variables)
__________________
Wolffy
------------------------
Teaching people to fish.

Reply With Quote
  #32  
Old May 5th, 2008, 04:31 PM
ArtJunky ArtJunky is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 87 ArtJunky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 39 m 9 sec
Reputation Power: 3
Any thoughts on how to save the ID using the SProc u sent?

Reply With Quote
  #33  
Old May 5th, 2008, 04:33 PM
ArtJunky ArtJunky is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 87 ArtJunky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 39 m 9 sec
Reputation Power: 3
OOPs I see there's a new page
I'll try that thanks.

I tried something like it but my page gave me an error. I'll have to look closer at what you sent

Reply With Quote
  #34  
Old May 5th, 2008, 04:40 PM
ArtJunky ArtJunky is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 87 ArtJunky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 39 m 9 sec
Reputation Power: 3
Quote:
Originally Posted by ArtJunky
OOPs I see there's a new page
I'll try that thanks.

I tried something like it but my page gave me an error. I'll have to look closer at what you sent


Yes, I cam up with exactly that, now that I took another look

The error:
Code:
Microsoft OLE DB Provider for SQL Server error '80040e10'

Procedure 'Insertuser' expects parameter '@CustID', which was not supplied.

/nupkshp.asp, line 192 

Reply With Quote
  #35  
Old May 6th, 2008, 07:50 AM
Wolffy's Avatar
Wolffy Wolffy is offline
Slaprentice of Wolves
Click here for more information.
 
Join Date: Aug 2007
Location: Mossville, IL
Posts: 1,015 Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 2 h 3 m 50 sec
Reputation Power: 329
You probably have it in the Procedure header rather than DECLAREing it.

Reply With Quote
  #36  
Old May 9th, 2008, 02:02 PM
ArtJunky ArtJunky is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 87 ArtJunky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 39 m 9 sec
Reputation Power: 3
More help?

Quote:
Originally Posted by Wolffy
You probably have it in the Procedure header rather than DECLAREing it.
I got past this error but I'm still on this. I got it mostly working: I can add a new file and if the user already exists, it doesn't add to either of the tables. However, now I'm trying to return the error if it fails or, if it succeeds in adding it, I'd like to display what I added on the page.

Using the previous example, how do I do this

Also, what is the "-10101" in the example that you gave to me? Is that a standard error code?

I also have a list of SQL 2000 error codes and the "547" that I included, does not exist.

Last edited by ArtJunky : May 9th, 2008 at 02:08 PM.

Reply With Quote
  #37  
Old May 9th, 2008, 03:19 PM
Wolffy's Avatar
Wolffy Wolffy is offline
Slaprentice of Wolves
Click here for more information.
 
Join Date: Aug 2007
Location: Mossville, IL
Posts: 1,015 Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 2 h 3 m 50 sec
Reputation Power: 329
The -10101 was just a number I made up. Tho, for SQL Server, user error should be >50,000 (if I remember correctly). So, check the return code from your ExecuteNonQuery to determine if the proc was successful or not.

To return a value from the sproc, you could use OUT parameters for this. However, there is no point if all you are doing is returning what was pass in to begin with.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > SQL Server 2000 - Store Procedure - Add new user - check before adding - return value if taken


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway