ASAP when I use cmd.ExecuteNonQueryAsync this happens Additional information: Syntax error in FROM clause, if I use cmd.ExecuteNonQuery this happens A

  • Thread starter Thread starter Lee Rae 18
  • Start date Start date
L

Lee Rae 18

Guest
public partial class ReceivedForm : Form
{
OleDbConnection con = new OleDbConnection(@"Provider = Microsoft.ACE.OLEDB.12.0;Data Source =C:\Users\user\Desktop\folder\databasefilename\database.accdb");


public ReceivedForm()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
this.Hide();
ReleasedForm f5 = new ReleasedForm();
f5.ShowDialog();
}

private void button2_Click(object sender, EventArgs e)
{
this.Hide();
RecordForm f6 = new RecordForm();
f6.ShowDialog();

}

private void button3_Click(object sender, EventArgs e)
{
Close();
}

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{

}

private void btn_view_Click(object sender, EventArgs e)
{

con.Open();

OleDbCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * FROM database";
cmd.ExecuteNonQueryAsync();
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd;
da.Fill(dt);
dataGridView1.DataSource = dt.DefaultView;

con.Close();
}


private void btn_insert_Click(object sender, EventArgs e)
{

OleDbCommand cmd;
con.Open();

DateTime d = new DateTime();
d = DateTime.Now;

textBox1.Text = d.ToString("dd.MM.yyyy");
textBox2.Text = d.ToString("HH:mm:ss");
cmd = new OleDbCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Add Items into Inventory('" + textBox1.Text + "', '" + textBox2.Text + "', '" + textBox3.Text + "', '" + textBox4.Text + "', '" + textBox5.Text + "', '" + textBox6.Text + "')";
cmd.ExecuteNonQueryAsync();
MessageBox.Show("Items and Info successfully added");
con.Close();


}
}
}

Continue reading...
 
Back
Top