Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
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:
  #1  
Old July 19th, 2005, 01:03 PM
jharnisch jharnisch is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 10 jharnisch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 13 m 48 sec
Reputation Power: 0
error in database

Hello,

I am getting an error in my stored procedure. i am gettin an error 213 which is column name or number does not match the table values. Here is the procedure:

CREATE PROCEDURE test
@Username nvarchar(50),
@Password nvarchar(50),
@Name nvarchar(50),
@Email nvarchar(50),
@Url nvarchar(400),
@Country nvarchar(50),
@Maillist nvarchar(50),
@CreditsEarned INT,
@CreditsUsed INT,
@RefEarned INT,
@RefCount INT,
@Purchased INT,
@held INT,
@pro nvarchar(50),
@timeframe nvarchar(100),
@REF nvarchar(50),
@status nvarchar(50)
AS
if exists(Select * From tblmain
Where Username = @Username)
return(1)
if exists(Select * From tblmain
Where Email = @Email)
return(2)
else
INSERT INTO tblmain
VALUES(@Username, @Password, @Name, @Email, @URL,@Country, @Maillist, @CreditsEarned,@CreditsUsed,@RefEarned,@RefCount,@ Purchased,@held, @pro,@timeframe, @REF, @status)

GO


Here is the database:

primary key ID int
username nvarchar
password nvarchar
email nvarchar
url nvarchar
country nvarchar
maillist nvarchar
creditsearned int
creditsused int
refearned int
refcount int
purchased int
held int
pro nvarchar
timeframe nvarchar
ref nvarchar
status nvarchar

I cant figure out why it isnt working

Reply With Quote
  #2  
Old July 26th, 2005, 05:07 PM
kcconnor's Avatar
kcconnor kcconnor is offline
Evil Republican...
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Probably running over your cat right now...
Posts: 250 kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level)kcconnor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 21 h 35 m 23 sec
Reputation Power: 37
I think this doesn't work because your first column in your table is a primary key, and you aren't specifying anything for it. Try changing your table definition for the PK so that is reads like this:

Code:
ID int PRIMARY KEY IDENTITY(1, 1)
...the rest of your table definition


And change your insert so that you aren't trying to insert @Username as the first entry into a column of type "int" that is the primary key. At the beginning of your 'values' string, make it look more like this:

Code:
INSERT INTO Table
VALUES (NULL, @Username, @Password, etc)

Reply With Quote
  #3  
Old July 26th, 2005, 05:25 PM
mehere's Avatar
mehere mehere is offline
Senior Sarcasm Wizardess
Click here for more information.
 
Join Date: Feb 2005
Location: Dreamland
Posts: 12,867 mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)mehere User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 10976 Folding Title: Novice Folder
Time spent in forums: 4 Months 4 Weeks 15 h 20 m 54 sec
Reputation Power: 1762
According to your list of the columns in your table ...
(@Username, @Password, @Name, @Email,)
The bolded one isn't listed:
primary key ID int
username nvarchar
password nvarchar
email nvarchar
url nvarchar

Also you could use an insert this way:
Code:
INSERT INTO tblmain (username, password, email, name, url, country, maillist, creditsearned, creditsused, refearned, refcount, purchased, held, pro, timeframe, ref, status) VALUES (@Username, @Password, @Name, @Email, @URL,@Country, @Maillist, @CreditsEarned,@CreditsUsed,@RefEarned,@RefCount,@  Purchased,@held, @pro,@timeframe, @REF, @status) 

so that values match up to the fields ...
Comments on this post
kcconnor agrees: Didn't even see the other problem with the additional parameters but no column. Good Eyes!
__________________
Come JOIN the party!!!

Quote of the Month:
Retirement: Because you've given so much of yourself to the company that you don't have anything left we can use.

Questions to Ponder:
What do you do when you see an endangered animal eating an endangered plant?

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright© 2008 sbenj69

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > error in database


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


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





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