Here is my code to insert data into a database.
code:
private void button2_Click(object sender, EventArgs
e)
{
//Insert Button
string connString = "Provider=Microsoft.ACE.OLEDB.12.0;" +
"Data Source = C:\project\patientDB.accdb";
OleDbConnection connection = new OleDbConnection(connString);
OleDbCommand cmd = connection.CreateCommand();
cmd.CommandText = "insert into Medical ([PatientID],[GeneralMedicalHistoryID],[Education] values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "' )";
connection.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Record Inserted");
connection.Close();
}
However it says syntax error in INSERT statement when I try to add. What am I doing wrong.
Here is a screenshot of the fields in the table.
You are missing to open connection before insert query .
you are calling "connection.Open();" after insert query. Remove from that place and place that code before insert query in same code.
Here is my code to insert data into a database. code: private void button2_Click(object sender, EventArgs...
Hi everyone, For my Assignment I have to use C# in order to create a validation form and include the following things to register and validate: Email Address, Username, Password, Retype Password, and a Submit Button. I have figured out some of the code for the Email Address validation: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Validation4 { public partial class Form1 : Form { ...
Here is my skeleton code to this C# assignement I need to add a few things, Change the the switch to If and Else-If statements (and test it is still working here) Add a third "Submit" button called SubmitButton In your If and Else-If add a condition if city is Honolulu and SubmitButton is checked. Display "Honolulu is the best place to be this time of year! I wish I was there!". Add comments, including header. HELP PLEASE ASAP public...
How can I print the Database table in PHP please ? here I have form for name and email, also I have php code that allow user to add his name and email to my database, all I need to print my final database when the user click on submit. <form action="" method="post"> <label>Name :</label> <input type="text" name="name" required="required" placeholder="Please Enter Name"/><br /><br /> <label>Email :</label> <input type="email" name="email" required="required" /><br/><br /> <input type="submit" value=" Submit " name="submit"/><br /> </form>...
I am working on integrating a database to an Android application for a course. Currently, I have all the database code done, but getting all of the EditText fields to enter data into the database has me stuck. Assignment objectives here, so we can be on the same page: Create a second page with a data entry form and the following fields: recipename, category, ingredients, and instructions. Make the Category field a dropdown box that contains the recipe categories listed...
This is a website picture The html and css code is as follow And my problem is as follow use the php and mysql Northwind Customer Database Search List Records All Records CustomerName v CustomerName ContactName Address City PostalCode Search O ASC DESC List All Records Insert Record Country List City CustomerName ContactName Address City PostalCode Country List City Find by IID Find Insert 1 <! DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http:L 3-<head> 4 Kmeta http-equiv-"Content-Type" content-"text/html; charset-utf-8" />...