Click here to Skip to main content
15,922,696 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Master page problem Pin
Amr M. K.3-Jun-07 22:57
Amr M. K.3-Jun-07 22:57 
QuestionImageButtton for edit in gridview Pin
ritu432129-May-07 19:42
ritu432129-May-07 19:42 
QuestionPlease convert this code in 2005 version Pin
siddisagar29-May-07 18:45
siddisagar29-May-07 18:45 
AnswerRe: Please convert this code in 2005 version Pin
Guffa29-May-07 19:02
Guffa29-May-07 19:02 
QuestionHow to Parse all items Pin
siddisagar29-May-07 17:54
siddisagar29-May-07 17:54 
AnswerRe: How to Parse all items Pin
N a v a n e e t h29-May-07 18:27
N a v a n e e t h29-May-07 18:27 
QuestionSpreadsheetML Problem Pin
jain.ashish2129-May-07 17:20
jain.ashish2129-May-07 17:20 
QuestionStored Procedure acting a bit strange Pin
J Liang29-May-07 15:35
J Liang29-May-07 15:35 
Hi,

I am facing this problem which I am not sure why this is happening, so here is what happened.

I have this stored procedure

CREATE PROCEDURE dbo.IsValidLogin
(
@username varchar(50) ,
@password varchar(12) ,
@userid int=0 OUTPUT,
@userfullname varchar(50) OUTPUT
)
AS

SELECT @userid=userid, @userfullname=userfullname
FROM tb_user
WHERE useremail=@username
AND userpassword=@password

GO

Then in my ASP.NET C# code, I do this,

//Call stored procedure from database to check validity of username and password
myCommand = new SqlCommand("IsValidLogin", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;

//Declare parameter for input and output of stored procedure
SqlParameter objParam1, objParam2, objParam3, objParam4;

objParam1 = myCommand.Parameters.AddWithValue("@username", SqlDbType.VarChar);
objParam2 = myCommand.Parameters.AddWithValue("@password", SqlDbType.VarChar);
objParam3 = myCommand.Parameters.AddWithValue("@userid", SqlDbType.Int);
objParam4 = myCommand.Parameters.AddWithValue("@userfullname", SqlDbType.VarChar);

objParam1.Direction = ParameterDirection.Input;
objParam2.Direction = ParameterDirection.Input;
objParam3.Direction = ParameterDirection.Output;
objParam4.Direction = ParameterDirection.Output;

objParam1.Value = uname;
objParam2.Value = upwd;

myCommand.ExecuteNonQuery();

if (objParam4.Value == System.DBNull.Value)
{
this.userid = 0;
this.userfullname = "";
}
else
{
this.userid = (int)objParam3.Value;
this.userfullname = (string)objParam4.Value;
}

This is actually a login page which I wanted to retrieve the user id and user full name, but when I login, I got this error message "System.Data.SqlClient.SqlException: Error converting data type varchar to int." It seems that it is the problem of this
"objParam4 = myCommand.Parameters.AddWithValue("@userfullname", SqlDbType.VarChar);" which is converting it to int, I did not make it to change to int but just don't understand why it wanted to convert.

Hope someone experience this before and do let me know why this is happening.

Thanks

J Liang
AnswerRe: Stored Procedure acting a bit strange Pin
N a v a n e e t h29-May-07 18:33
N a v a n e e t h29-May-07 18:33 
GeneralRe: Stored Procedure acting a bit strange Pin
J Liang29-May-07 20:32
J Liang29-May-07 20:32 
AnswerRe: Stored Procedure acting a bit strange Pin
Harini N K29-May-07 18:42
Harini N K29-May-07 18:42 
GeneralRe: Stored Procedure acting a bit strange Pin
Guffa29-May-07 19:17
Guffa29-May-07 19:17 
GeneralRe: Stored Procedure acting a bit strange Pin
J Liang29-May-07 20:31
J Liang29-May-07 20:31 
AnswerRe: Stored Procedure acting a bit strange Pin
Guffa29-May-07 19:12
Guffa29-May-07 19:12 
GeneralRe: Stored Procedure acting a bit strange Pin
J Liang29-May-07 20:27
J Liang29-May-07 20:27 
AnswerRe: Stored Procedure acting a bit strange Pin
Harini N K29-May-07 19:49
Harini N K29-May-07 19:49 
QuestionInput Validation with Dynamically created DetailsView? Pin
Nancy K29-May-07 13:49
Nancy K29-May-07 13:49 
QuestionCascadingdropdown in ajax Pin
seemamltn29-May-07 13:12
seemamltn29-May-07 13:12 
AnswerRe: Cascadingdropdown in ajax Pin
Christian Graus29-May-07 13:46
protectorChristian Graus29-May-07 13:46 
QuestionDate time picker Pin
teddddddddddd29-May-07 10:31
teddddddddddd29-May-07 10:31 
AnswerRe: Date time picker Pin
Christian Graus29-May-07 13:47
protectorChristian Graus29-May-07 13:47 
GeneralRe: Date time picker Pin
teddddddddddd29-May-07 19:30
teddddddddddd29-May-07 19:30 
QuestionPrinting Datagrids in ASP.net Pin
umashankergr829-May-07 6:05
umashankergr829-May-07 6:05 
AnswerRe: Printing Datagrids in ASP.net Pin
Suresh Pirsquare29-May-07 7:11
Suresh Pirsquare29-May-07 7:11 
QuestionOverwriting controls contents Pin
totig29-May-07 5:42
totig29-May-07 5:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.