DbManager Class

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a DbManager class that has all my connect stuff like connecting to the
bd and inserting data, but for some reason when I call the insert coammand
for the DbManager class I get A Method 'Network_Inventory.DbManager.Insert()'
referenced without parentheses

Here is my DbManager Class code
public void Insert()
{
OleDbCommand cmdInsert = new OleDbCommand();
cmdInsert.ExecuteNonQuery();
}
Here is my save btn that calls it
private void btnSave_Click(object sender, System.EventArgs e)
{
DbManager manager = new DbManager();
manager.conn();
manager.Insert = "insert into Wired(RouterName) values ('" +
txtRouterName.Text + "')";
}
Can some one help
 
It looks like you're using Insert as a property when it's actually a method,
see inline:

freddy said:
I have a DbManager class that has all my connect stuff like connecting to
the
bd and inserting data, but for some reason when I call the insert coammand
for the DbManager class I get A Method
'Network_Inventory.DbManager.Insert()'
referenced without parentheses

Here is my DbManager Class code
public void Insert()
{
OleDbCommand cmdInsert = new OleDbCommand();
cmdInsert.ExecuteNonQuery();
}
Here is my save btn that calls it
private void btnSave_Click(object sender, System.EventArgs e)
{
DbManager manager = new DbManager();
manager.conn();
manager.Insert = "insert into Wired(RouterName) values ('" +
txtRouterName.Text + "')";

should be:
manager.Insert("insert into Wired(RouterName) values ('" +
txtRouterName.Text + "')");
}
Can some one help

Just a work of warning, using the above code leaves you wide open to SQL
injection attacks. Whenever possible you should use parameters instead of
just concatenating strings.
 
BTW, the code you posted could potentially open you up to SQL Injection
attacks. You might consider using parameterized queries instead.

Thx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top