插入错误列名称或提供的值数与表定义不匹配

时间:2014-04-15 07:55:07

标签: c# asp.net sql-server

ALTER PROCEDURE dbo.storMember 
( 
    @Check nchar (1), 
    @UserName nvarchar (15), 
    @Passowerd nvarchar (15)=null, 
    @Name nvarchar (15)=null, 
    @Phone nvarchar (15)=null, 
    @email nvarchar (30)=null, 
    @CompanyName nvarchar (15)=null , 
    @Gender nvarchar (15)=null, 
    @BarthDay datetime =null, 
    @Question nvarchar (15)=null, 
    @answer nvarchar (100)=null ) 
AS 

if @check = 'a' 
    begin 
        insert into Member values
       (@Check,@UserName,@Passowerd,@Name,@Phone,@email,@CompanyName,@Gender,@BarthDay,@Question,@answer) 
    end

if @Check = 'u'
    begin
        UPDATE Member 
        SET Passowerd = @Passowerd, 
        [Name] = @Name, 
        Phone = @Phone,
        email =@email, 
        CompanyName = @CompanyName, 
        Gender = @Gender, 
        BarthDay = @BarthDay, 
        Question = @Question, 
        Answer = @Answer 
        WHERE (UserName=@UserName) 
    end 

if @check= 'd'
    begin 
        Delete from member 
        where (userName = @userName) 
    end 
return

2 个答案:

答案 0 :(得分:1)

如果要在特定列中插入值,请指定列名。

insert into Member (CheckColumnName,Usernamecolumnname,NamecolumnName,PhoneColumnName,EmailColumnName,CompanyNameColumnNmae,GenderColumnNmae,BarthdayColumnNmae,QuestionColumnName,AnswerColumnName) values
   (@Check,@UserName,@Passowerd,@Name,@Phone,@email,@CompanyName,@Gender,@BarthDay,@Question,@answer) 

答案 1 :(得分:0)

这里是sql server ...

如果你想正确插入..

1>转到数据库

2 - ;右键单击表

3>选项:“脚本表为”

4>然后“插入”

您将获得整个表格查询 然后根据专栏传递你的所有参数。