Error 1 No overload for method 'AddWithValue' takes '1' arguments [Resolved]

Posted by Sudheep.grandhe under C# on 11/7/2011 | Points: 10 | Views : 3461 | Status : [Member] | Replies : 1
Hi,

In the coding it shows the following error.
public void getdata()
{
DataTable dt=new DataTable ();
SqlConnection con=new SqlConnection ("data source=mars-104;initial catalog=marsweb;integrated security=true");
con .Open ();
SqlCommand cmd=new SqlCommand ("select compname,compaddress,invoiceno,orderno,ondate,invoicedate,netamount,netvat,tamount from tbl_Report2 WHERE invoiceno=@invoiceno )",con );
SqlDataAdapter da=new SqlDataAdapter (cmd );
cmd.Parameters.AddWithValue("@invoiceno");//error shows here
da .Fill (dt );

Best,
Sudheep.



Responses

Posted by: Blessyjees on: 11/7/2011 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Hi,

You should specify the value of parameter like cmd.Parameter.AddWithValue("@invoiceno", 123);

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparametercollection.addwithvalue.aspx

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

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

Login to post response