Iv'e been searching this website forums for the right answer but i didn't find. Im using VS2008 and want to build some application that working with microsoft access database. in the database i have one table call "customers" with the coulmns = "firstName", "lastName", "address" etc.. I want to make form with the same textbox that will send the data to the database. I have some background in ASP.NET and i build some websites with asp.net but i guess its not the same syntax cause in Windows Applications this is not working. PLEASE HELP ME WITH THE RIGHT CODE..... just for sample here is the code that im writting:
private void addNewCustomer_Click(object sender, EventArgs e)
{
OleDbConnection reemConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\WindowsFormsApplication2\forumArt.accdb");
OleDbCommand objCmd = new OleDbCommand("Insert into customers (firstName, lastName, address, city) values (@firstName,@lastName,@address,@city)", reemConnection);
objCmd.Parameters.Add("@firstName", OleDbType.VarChar).Value = firstName.Text;
objCmd.Parameters.Add("@lastName", OleDbType.VarChar).Value = lastName.Text;
objCmd.Parameters.Add("@address", OleDbType.VarChar).Value = address.Text;
objCmd.Parameters.Add("@city", OleDbType.VarChar).Value = city.Text;
if (firstName.Text == string.Empty || address.Text == string.Empty)
{
MessageBox.Show("Please Fillup the first name and the address fields");
return;
}
reemConnection.Open();
reemConnection.Close();
Close();
}
Thanks a lot