Ajay
Ajay

Reputation: 45

confused about parameters passed to cmd.Parameters.Add()

I am going to delete a single record from report returned by gridView, I have added edit and delete buttons in a Gridview itself, I have kept Empno=@1 in a where clause of delete query please explain what is '12' in below line.

command.Parameters.Add("@1", SqlDbType.Int,12);

Upvotes: 0

Views: 165

Answers (2)

shreesha
shreesha

Reputation: 1881

I am not sure about your framework version.Framework version 3.5 and above command .parameters.Add method is deprecated and replaced by AddWithValue.check the link.For the reason behind check this

Syntax is

public SqlParameter AddWithValue(
    string parameterName,
    Object value
)

Usage is

    string commandText = "select * from Sales.Store WHERE CustomerID = @ID;";
    command.Parameters.AddWithValue("@ID", ID);

Upvotes: 0

Ghanshyam Baravaliya
Ghanshyam Baravaliya

Reputation: 147

command.Parameters.Add("@1", SqlDbType.Int,12);

-@1 is parameter name which given in query/store procedure
-SqlDbType.Int is type of parameter 
-12 is values given to parameter 

Upvotes: 2

Related Questions