|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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) |
|
#3
|
||||
|
||||
|
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 ...
__________________
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 |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > error in database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|