Hi,
Error 1:-The best overloaded method match for 'System.Data.SqlClient.SqlParameterCollection.AddWithValue(string, object)' has some invalid arguments.I am underliying the error part.please find.
private void btn_add_Click(object sender, EventArgs e)
{
string strondate, strondate1, ondate;
string strinvoicedate, strinvoicedate1, invoicedate2;
SqlConnection con = new SqlConnection("data source=mars-104;intial catalog=marsweb.imageimpacts;integrated security=true");
SqlCommand cmd = new SqlCommand("insert into tbl_temp (invoiceno,particulars,quantiy,perprice,amount,orderno,compname,invoicedate,ondate,invoiceid)values(@invoiceno,@particulars,@quantity,@perprice,@amount,@orderno,@compname,@invoicedate,@ondate,@invoiceid)", con);
cmd.Parameters.AddWithValue("@invoiceno", txt_invoiceno.Text);
cmd.Parameters.AddWithValue("@particulars", cmb_particulars.SelectedItem.ToString);
cmd.Parameters.AddWithValue("@quantity", txt_quantity.Text);
cmd.Parameters.AddWithValue("@perprice", txt_perprice.Text);
cmd.Parameters.AddWithValue("@amount", txt_amount.Text);
cmd.Parameters.AddWithValue("@orderno", txt_orderno.Text);
cmd.Parameters.AddWithValue("@compname", cmb_companyname.SelectedItem.ToString);
Error 2:-Argument '2': cannot convert from 'method group' to 'object' .I am underliying the error part.please find.
private void cmb_companyname_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("data source=mars-104;intial catalog=marsweb.imageimpacts;integrated security=true");
SqlCommand cmd = new SqlCommand("select custaddress from tbl_customer where custname=@custname", con);
cmd.Parameters.AddWithValue("@compname",
cmb_companyname.SelectedItem.ToString) ;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
txt_customeraddress.Text = dt.Rows[0][0].ToString();
}
Best,
Sudheep.
Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator