im trying to update my stores stock levels with the use of a button, when this button is pressed i want all the quantities to be increased by the amount in the text box, ive had a go implementing some code to do this but it always hits the data not inserted message...
using System;
using System.Data;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace Aliena_Store
{
public partial class Form3 : Form
{
MySqlConnection connection = new MySqlConnection("server=localhost;user=root;database=Aliena_Store;port=3306;password=Blackie");
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
{
//MySqlConnection(VarribleKeeper.MySQLConnectionString);
connection.Open();
MySqlDataAdapter MyDA = new MySqlDataAdapter();
string sqlSelectAll = "SELECT * From Aliena_Store.Game_Details";
MyDA.SelectCommand = new MySqlCommand(sqlSelectAll, connection);
DataTable table = new DataTable();
MyDA.Fill(table);
BindingSource bSource = new BindingSource();
bSource.DataSource = table;
dataGridView1.DataSource = bSource;
}
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void SeeForm2_Click(object sender, EventArgs e)
{
Hide();
Form2 f = new Form2(); // This is bad
f.Show();
}
private void button1_Click(object sender, EventArgs e)
{
string updateQuery = ("UPDATE Aliena_Store.Game_details SET Quantity = '" + AddStock.Text + "'");
try
{
MySqlCommand command = new MySqlCommand(updateQuery, connection);
if (command.ExecuteNonQuery() == 1)
{
MessageBox.Show("DATA UPDATED");
}
else
{
MessageBox.Show("Data NOT UPDATED");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void AddStock_TextChanged(object sender, EventArgs e)
{
}
}
}
any clue where my code is going wrong?