Non-invocable member 'marsweb.imageimpacts.customerupdate.listboxcustomers' cannot be used like a me

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

in my coding it shows the following error.please do the needful.

Error1:-Non-invocable member 'marsweb.imageimpacts.customerupdate.listboxcustomers' cannot be used like a method. Here is my code.
public customerupdate()
{
InitializeComponent();
string ConnectionString = "data source=mars-104;" +"initial catalog=marsweb;integrated security=true";
string CommandString = "select * from tbl_customer";
_dataadapter = new SqlDataAdapter(CommandString, ConnectionString);
_dataset = new DataSet();
_dataadapter.Fill(_dataset, "tbl_customer");
this.listboxcustomers ();//here it shows the error.
}

Best,
Sudheep.



Responses

Posted by: Blessyjees on: 11/23/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

Please priovide the code of this.listboxcustomers ();

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

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

Posted by: Sudheep.grandhe on: 11/23/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Chechi,

here is my code.please find it.

public partial class customerupdate : Form
{
private SqlDataAdapter _dataadapter;
private DataTable _datatable;
private DataSet _dataset;
public customerupdate()
{
InitializeComponent();
string ConnectionString = "data source=mars-104;" +"initial catalog=marsweb;integrated security=true";
string CommandString = "select * from tbl_customer";
_dataadapter = new SqlDataAdapter(CommandString, ConnectionString);
_dataset = new DataSet();
_dataadapter.Fill(_dataset, "tbl_customer");
this.listboxcustomers ();
}
private void AddParms(SqlCommand cmd, params string[] cols)
{
foreach (string column in cols)
{
cmd.Parameters.Add("@" + column, SqlDbType.Char, 0, column);
}
}

private void InitializeCommands()
{
SqlConnection con = (SqlConnection)_dataadapter.SelectCommand.Connection;
_dataadapter.InsertCommand = con.CreateCommand();
_dataadapter.InsertCommand.CommandText = "insert into tbl_customer" + "(custid,custname,custaddress,custcity," + "custstate,custstdcode,custphoneno,custmobilno)" + "values(@custid,@custname,@custaddress,@custcity," + "@custstate,@custstdcode,@custphoneno,@custmobileno)";
this.AddParms(_dataadapter.InsertCommand, "custid", "custname", "custaddress", "custcity", "custstate", "custstdcode", "custphoneno", "custmobileno");
_dataadapter.UpdateCommand = con.CreateCommand();
_dataadapter.UpdateCommand.CommandText = "update tbl_customer" + "set custaddress=@custaddress " + "where custid=@custid";
this.AddParms(_dataadapter.UpdateCommand, "custaddress", "custid");
}
private void PopulateListBox()
{
_datatable = _dataset.Tables[0];
listboxcustomers.Items.Clear();
foreach (DataRow datarow in _datatable.Rows)
{
listboxcustomers.Items.Add(datarow["custid"] + "," + datarow["custname"] + "," + datarow["custaddress"] + "," + datarow["custcity"] + "," + datarow["custstate"] + "," + datarow["custstdcode"] + "," + datarow["custphoneno"] + "," + datarow["custmobileno"] + ")");
}
}
private void ClearFields()
{
txt_customername.Text = "";
txt_customeraddress.Text = "";
txt_custcity.Text = "";
txt_customerstate.Text = "";
txt_stdcode.Text = "";
txt_phoneno.Text = "";
txt_mobileno.Text = "";
}
private void btn_updateselectedcustomername_Click(object sender, EventArgs e)
{
int index;
index = listboxcustomers.SelectedIndex;
if (index == (-1))
{
MessageBox.Show("please select customer name");
return;
}
else
{
lblmsg.Text = "";
}
DataRow targetrow = _datatable.Rows[index];
MessageBox .Show ("updating: " + targetrow ["custaddress"]);
Application.DoEvents();
targetrow.BeginEdit();
targetrow["custaddress"] = txt_customeraddress.Text;
targetrow.EndEdit();
DataSet datasetchanged=_dataset .GetChanges (DataRowState .Modified );
bool okayflag = true;
if (datasetchanged.HasErrors)
{
okayflag = false;
string msg = "error in row with custid";
foreach (DataTable thetable in datasetchanged.Tables)
{
if (thetable.HasErrors)
{
DataRow[] errorrows = thetable.GetErrors();
foreach (DataRow therow in errorrows)
{
msg = msg + therow["custid"];
}
}
}
lblmsg.Text = msg;
if (okayflag)
{
_dataadapter.Update(datasetchanged, "tbl_customer");
MessageBox.Show("update" + targetrow["custaddress"]);
Application.DoEvents();
_dataset.AcceptChanges();
PopulateListBox();
}
else
{
_dataset.RejectChanges();
}
}
}


Best,
Sudheep.

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

Posted by: Blessyjees on: 11/23/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

"this.listboxcustomers (); " is it a method call. if no comment this code and try again.

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