Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
first i have mention that i m very new to this asp.net so plese if my error is to small then also give me the answer....
i have made one store procedure name insertstudent and its look like.
create procedure insertstudent @firstname varchar(50),@lastname varchar(50),@gender varchar(50),@address varchar(50),@phone varchar(50),@dob datetime,@email varchar(50)
as
insert into student values(@firstname varchar(50),@lastname varchar(50),@gender varchar(50),@address varchar(50),@phone varchar(50),@dob datetime,@email varchar(50))
and i m getting error like..
Msg 102, Level 15, State 1, Procedure insertstudent, Line 3
Incorrect syntax near 'varchar'.
i couldnt find the error...plese anyone help me....
Posted
Comments
[no name] 22-Jul-12 15:09pm    
insert into student values(@firstname,@lastname,@gender,@address,@phone,@dob ,@email)

you should write below code




SQL
create procedure insertstudent
@firstname varchar(50),@lastname varchar(50),@gender varchar(50),@address varchar(50),@phone varchar(50),@dob datetime,@email varchar(50)
as
insert into student values(@firstname,@lastname ,@gender ,@address ,@phone ,@dob ,@email )
 
Share this answer
 
Comments
pandya purvang 22-Jul-12 15:17pm    
Thanks man its working..............thanks lot!!
Your insert is not correct.

It should read

SQL
Insert into Student( firstname, lastname, gender, address, phone, dob, email)
values (@firstname, @lastname, @gender, @address, @phone, @dob, @email)


Basically the insert line (line 1) should be the columns you want to insert into.
The second (values line 2) should be the values of the parameters.

You could re-write this to (Providing that the columns in your table are in the same order as the parameters):

SQL
insert into Student
select @firstname, @lastname, @gender, @address, @phone, @dob, @email
 
Share this answer
 
Comments
pandya purvang 22-Jul-12 15:21pm    
yeahhh thanks its working.........next time i will better see this...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900