| Author |
Topic |
|
yanivz
Starting Member
3 Posts |
Posted - 2009-12-13 : 20:51:25
|
i have this stored procedureALTER PROCEDURE sp_login ( @LoginNumber VARCHAR(255), @UserName VARCHAR(255), @Password VARCHAR(255), @Active BIT OUTPUT )ASSELECT @Active = ActiveFROM UsersWHERE (LoginNumber = @LoginNumber) AND (UserName = @UserName) AND (Password = @Password) i have records in users table and the stored procedure does not returns records when i execute.can someone tell me what is wrong here, please ? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-12-13 : 21:01:38
|
does the parameters pass in matches with the column values in the tables ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-12-14 : 00:20:35
|
quote: Originally posted by yanivz i have this stored procedureALTER PROCEDURE sp_login ( @LoginNumber VARCHAR(255), @UserName VARCHAR(255), @Password VARCHAR(255), @Active BIT OUTPUT )ASSELECT @Active = ActiveFROM UsersWHERE (LoginNumber = @LoginNumber) AND (UserName = @UserName) AND (Password = @Password) i have records in users table and the stored procedure does not returns records when i execute.can someone tell me what is wrong here, please ?
Where you put the Return statement or select statement???ALTER PROCEDURE sp_login ( @LoginNumber VARCHAR(255), @UserName VARCHAR(255), @Password VARCHAR(255), @Active BIT OUTPUT )ASSELECT @Active = ActiveFROM UsersWHERE (LoginNumber = @LoginNumber) AND (UserName = @UserName) AND (Password = @Password)SELECT @Active Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-12-14 : 00:34:49
|
HiYou fine with this...ALTER PROCEDURE sp_login ( @LoginNumber VARCHAR(255), @UserName VARCHAR(255), @Password VARCHAR(255))ASSELECT ActiveFROM UsersWHERE (LoginNumber = @LoginNumber) AND (UserName = @UserName) AND (Password = @Password) -------------------------R... |
 |
|
|
yanivz
Starting Member
3 Posts |
Posted - 2009-12-14 : 05:39:59
|
| to khtan yes,the parameters pass in matches with the column values in the tables.to senthil_nagore the SELECT @Active is the return valueand rajdaksha that thank you but i like to use my sp any suggestion? still not getting records... |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-12-14 : 05:48:04
|
can you show us how do you call sp_login ?make sure you specify the OUTPUT keyword thereand if you are expecting a record to return from your sp, it does not. It is returning the Active via output parameter KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
yanivz
Starting Member
3 Posts |
Posted - 2009-12-14 : 13:44:12
|
in the sql server management i just execute it and fill the parameters (not Active )in the code i use the following : bool SuccessfulLogin() { string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; // Your code should get the connection string from web.config using (SqlConnection conn = new SqlConnection(connectionString)) { using (SqlCommand cmd = new SqlCommand("sp_login")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@LoginNumber", txtLoginNumber.Text)); cmd.Parameters.Add(new SqlParameter("@UserName", txtUserName.Text)); cmd.Parameters.Add(new SqlParameter("@Password", txtPassword.Text)); SqlParameter countParameter = new SqlParameter("@Active", SqlDbType.Bit,0); countParameter.Direction = ParameterDirection.Output; cmd.Parameters.Add(countParameter); conn.Open(); cmd.Connection = conn; cmd.ExecuteNonQuery(); conn.Close(); return bool.Parse(cmd.Parameters["@Active"].Value.ToString()); } } }} |
 |
|
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2009-12-14 : 13:49:12
|
| Do you know how to step through stored procedures (from visual studio, create a database project and then you see exactly where you missing out). |
 |
|
|
|