dbo.net errors occuring in passing parameters to stored procedures [Resolved]

Posted by Amzu14 under Error and Solution on 7/27/2010 | Views : 2038 | Status : [Member] | Replies : 2

I am passing values from textboxes on the webform to my stored procedures where it should insert values passed. It is giving an error like Cannot implicitly convert type 'string' to 'System.Data.SqlClient.SqlParameter' at place where I am cmdselect.Parameters.Add("@PackageName", SqlDbType.VarChar, 50) = PN;
where PN is string type .
Please somebody help me.




Responses

Posted by: Vanchi050585 on: 7/29/2010 [Member] Starter

Up
0
Down

Resolved
hai friend,

pls try it
cmdselect.Parameters.Add("@PackageName", SqlDbType.VarChar, 50).value = PN;

i think it work very fine.

dont forgot the Mark as answer.

Thanks
tvn

Amzu14, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raja on: 7/27/2010 [Member] Starter

Up
0
Down
Do not go for shortcut and specify the parameter type and value in the same line.\

Use something like below and it should work.

SqlParameter prms = new SqlParameter("@tokenCode", SqlDbType.VarChar, 50);

prms.Value = PN;
cmdselect.Parameters.Add(prms);


Hope thsi will help.

Thanks for asking.


Regards,
Raja, USA

Amzu14, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response