I'm new to .NET.
when I 'm trying to execute the following code I got an InvalidCastException error
string FirstName = "txtFirstName";// get username from user
string SecondName = "txtSecondName" ;// get password from user
SqlConnection conn = new SqlConnection("Data Source=localhost;Database=db2;Integrated Security=SSPI");
SqlCommand command = new SqlCommand("InsertUser", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = txtFirstName;
command.Parameters.Add("@SecondName", SqlDbType.VarChar).Value = txtSecondName;
int rows = command.ExecuteNonQuery();//showing error in this line.
I'm using the following stored procedure
ALTER PROCEDURE dbo.InsertUser
INSERT into details VALUES(@FirstName,@SecondName)
What is causing this error? What can I do? Can anyone help me....
|All times are GMT. The time now is 06:26 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.