Hi,
i want to update the details in a form it shows the errors(windows applications)?.please do the needful/
Errors:
Error:-Operator '==' cannot be applied to operands of type 'System.Windows.Forms.TextBox' and 'string'
Error:-Operator '||' cannot be applied to operands of type 'bool' and 'string'
Error:-The best overloaded method match for 'System.Data.SqlClient.SqlCommand.SqlCommand(string, System.Data.SqlClient.SqlConnection)' has some invalid arguments
Error:-Argument '2': cannot convert from 'System.Data.SqlClient.SqlCommand' to 'System.Data.SqlClient.SqlConnection'
private void btn_update_Click(object sender, EventArgs e)
{
try
{
if ((txt_customeraddress.Text == "" || txt_invoiceno.Text == "" || txt_orderno.Text = ""))
{
MessageBox.Show("Fill All Entries:");
}
else if (txt_customeraddress == txt_customeraddress.Text && txt_invoiceno.Text == txt_invoiceno.Text && txt_orderno.Text == txt_orderno.Text)
{
}
else
{
SqlCommand cmd = new SqlCommand("update tbl_report2 set compname=@compname,compaddress=@compaddress,orderno=@orderno,ondate=@ondate,invoicedate=@invoicedate,amountstatus=@amountstatus,netamount=@netamount,tamount=@tamount where invoiceno=@id", cmd);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@compname", cmb_companyname.Text);
cmd.Parameters.AddWithValue("@compaddress", txt_customeraddress.Text);
cmd.Parameters.AddWithValue("@id", txt_invoiceno.Text);
cmd.Parameters.AddWithValue("@orderno", txt_orderno.Text);
cmd.ExecuteNonQuery();
MessageBox.Show("Data Successfully Updated");
}
}
catch (Exception ae) { MessageBox.Show(ae.ToString()); }
}
}
Best,
Sudheep.