Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to insert user login detail in table by using following storeprocedure

create procedure sp_jobseekerLogin
@user_type varchar(100)=null,
@user_name varchar(100)=null,
@password varchar(100)=null,
@Email varchar(100)=null,
@firstName varchar(30)=null,
@mobile varchar(20)=null,
@user_address varchar(500)=null,
@active varchar(10) =null,
@user_id int output
as
begin
insert into JP_Login(user_type,user_name,password,user_email,first_name,mobile,user_address,active,date) values
(@user_type,@user_name,@password,@Email,@firstName,@mobile,@user_address,@active,GETDATE())

set @user_id=@@IDENTITY
end


I am new in using linq to sql

below is my c# code,facing problem in passing the parameter can any one help me...
C#
public int insertlogin()
       {
         DataClasses1DataContext  db = new DataClasses1DataContext();
           int userid = db.sp_jobseekerLogin(2, txtUserName.Text, txtpassword.Text, txtEmail.Text, txtFullName.Text, txtmobile.Text, txtcurntLoc.Text, "y",);
           db.SubmitChanges();
           return userid;
       }</pre>
Posted
Comments
[no name] 14-May-14 0:17am    
what is the problem?

1 solution

since you have output parameter as user id, you need to use ref keyword

C#
int userid = 0;

db.sp_jobseekerLogin(...., ref userid, ....);
 
Share this answer
 
v2
Comments
Member 10310320 14-May-14 0:28am    
public int insertlogin()
{

db = new DataClasses1DataContext();
int? user_id = 0;
int userid = db.sp_jobseekerLogin(2,txtUserName.Text,txtpassword.Text,txtEmail.Text,txtFullName.Text,txtmobile.Text,txtcurntLoc.Text,"y",ref user_id);
db.SubmitChanges();
return userid;
}
using like this still i am getting error
DamithSL 14-May-14 0:29am    
you don't need db.SubmitChanges();
what is the error?
DamithSL 14-May-14 0:32am    
and which parameter you set as 2? you have string parameters except user id.
Member 10310320 14-May-14 0:33am    
The overload method has some invalid arguments
DamithSL 14-May-14 0:36am    
problem is with parameter you send as 2, try with "2" as string

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