End Google Ads 201810 - BS.net 01 --> i take this program in c# from code project and this code is written by phd student in UK and he from jordon
when i try to modfiy it i hove some problem in insert & update (syntax error ) but the search and delete is work fine
here is the complet code after my modifying


can you help me pls



using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
namespace WindowsApplication1
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Button Add_btn;
private System.Windows.Forms.Button up_btn;
private System.Windows.Forms.Button del_btn;
private System.Windows.Forms.Button find_btn;
private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
private System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
private System.Data.OleDb.OleDbCommand oleDbInsertCommand1;
private System.Data.OleDb.OleDbCommand oleDbUpdateCommand1;
private System.Data.OleDb.OleDbCommand oleDbDeleteCommand1;
private System.Data.OleDb.OleDbConnection oleDbConnection1;
private WindowsApplication1.DataSet1 dataSet11;
private System.Windows.Forms.Label qurey_label;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.textBox1 = new System.Windows.Forms.TextBox();
this.dataSet11 = new WindowsApplication1.DataSet1();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.Add_btn = new System.Windows.Forms.Button();
this.up_btn = new System.Windows.Forms.Button();
this.del_btn = new System.Windows.Forms.Button();
this.find_btn = new System.Windows.Forms.Button();
this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
this.oleDbDeleteCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand();
this.qurey_label = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "Db.ID", true));
this.textBox1.******** = new System.Drawing.Point(104, 64);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(216, 20);
this.textBox1.TabIndex = 0;
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("en-US");
this.dataSet11.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
//
// textBox2
//
this.textBox2.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "Db.dnasequence", true));
this.textBox2.******** = new System.Drawing.Point(104, 104);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(216, 20);
this.textBox2.TabIndex = 1;
//
// textBox3
//
this.textBox3.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "Db.p-name", true));
this.textBox3.******** = new System.Drawing.Point(104, 144);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(216, 20);
this.textBox3.TabIndex = 2;
//
// textBox4
//
this.textBox4.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet11, "Db.address", true));
this.textBox4.******** = new System.Drawing.Point(104, 184);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(216, 20);
this.textBox4.TabIndex = 3;
//
// label1
//
this.label1.******** = new System.Drawing.Point(16, 64);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 23);
this.label1.TabIndex = 4;
this.label1.Text = "ID";
//
// label2
//
this.label2.******** = new System.Drawing.Point(16, 104);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 23);
this.label2.TabIndex = 5;
this.label2.Text = "dnasequence";
//
// label3
//
this.label3.******** = new System.Drawing.Point(16, 144);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 23);
this.label3.TabIndex = 6;
this.label3.Text = "p-name";
//
// label4
//
this.label4.******** = new System.Drawing.Point(16, 184);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(80, 23);
this.label4.TabIndex = 7;
this.label4.Text = "address";
//
// Add_btn
//
this.Add_btn.******** = new System.Drawing.Point(40, 16);
this.Add_btn.Name = "Add_btn";
this.Add_btn.Size = new System.Drawing.Size(75, 23);
this.Add_btn.TabIndex = 8;
this.Add_btn.Text = "Add";
this.Add_btn.Click += new System.EventHandler(this.Add_btn_Click);
//
// up_btn
//
this.up_btn.******** = new System.Drawing.Point(136, 16);
this.up_btn.Name = "up_btn";
this.up_btn.Size = new System.Drawing.Size(75, 23);
this.up_btn.TabIndex = 9;
this.up_btn.Text = "Update";
this.up_btn.Click += new System.EventHandler(this.up_btn_Click);
//
// del_btn
//
this.del_btn.******** = new System.Drawing.Point(240, 16);
this.del_btn.Name = "del_btn";
this.del_btn.Size = new System.Drawing.Size(75, 23);
this.del_btn.TabIndex = 10;
this.del_btn.Text = "Delete";
this.del_btn.Click += new System.EventHandler(this.del_btn_Click);
//
// find_btn
//
this.find_btn.******** = new System.Drawing.Point(16, 312);
this.find_btn.Name = "find_btn";
this.find_btn.Size = new System.Drawing.Size(320, 24);
this.find_btn.TabIndex = 11;
this.find_btn.Text = "Find";
this.find_btn.Click += new System.EventHandler(this.find_btn_Click);
//
// oleDbDataAdapter1
//
this.oleDbDataAdapter1.DeleteCommand = this.oleDbDeleteCommand1;
this.oleDbDataAdapter1.InsertCommand = this.oleDbInsertCommand1;
this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "Db", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("ID", "ID"),
new System.Data.Common.DataColumnMapping("dnasequence", "dnasequence"),
new System.Data.Common.DataColumnMapping("address", "address"),
new System.Data.Common.DataColumnMapping("p-name", "p-name")})});
this.oleDbDataAdapter1.UpdateCommand = this.oleDbUpdateCommand1;
//
// oleDbDeleteCommand1
//
this.oleDbDeleteCommand1.CommandText = "DELETE FROM Db WHERE (ID = ?) AND (address = ? OR ? IS NULL AND addonNumber IS NU" +
"LL) AND (dnasequence = ? OR ? IS NULL AND dnasequence IS NULL) AND (p-name = ? O" +
"R ? IS NULL AND p-name IS NULL)";
this.oleDbDeleteCommand1.Connection = this.oleDbConnection1;
this.oleDbDeleteCommand1.Parameters.AddRange(new System.Data.OleDb.OleDbParameter[] {
new System.Data.OleDb.OleDbParameter("Original_ID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((byte)(10)), ((byte)(0)), "ID", System.Data.DataRowVersion.Original, null),
new System.Data.OleDb.OleDbParameter("Original_address", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "address", System.Data.DataRowVersion.Original, null),
new System.Data.OleDb.OleDbParameter("Original_address1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "address", System.Data.DataRowVersion.Original, null),
new System.Data.OleDb.OleDbParameter("Original_dnasequence", System.Data.OleDb.OleDbType.VarWChar, 200, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "dnasequence", System.Data.DataRowVersion.Original, null),
new System.Data.OleDb.OleDbParameter("Original_dnasequence1", System.Data.OleDb.OleDbType.VarWChar, 200, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "dnasequence", System.Data.DataRowVersion.Original, null),
new System.Data.OleDb.OleDbParameter("Original_p-name", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "p-name", System.Data.DataRowVersion.Original, null),
new System.Data.OleDb.OleDbParameter("Original_p-name1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "p-name", System.Data.DataRowVersion.Original, null)});
//
// oleDbConnection1
//
this.oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\MOHAMMED\\Downloads\\Ado_src\\" +
"WindowsApplication1\\Db.mdb";
//
// oleDbInsertCommand1
//
this.oleDbInsertCommand1.CommandText = "INSERT INTO Db(p-name, address, ID, dnasequence) VALUES (?, ?, ?, ?)";
this.oleDbInsertCommand1.Connection = this.oleDbConnection1;
this.oleDbInsertCommand1.Parameters.AddRange(new System.Data.OleDb.OleDbParameter[] {
new System.Data.OleDb.OleDbParameter("p-name", System.Data.OleDb.OleDbType.VarWChar, 50, "p-name"),
new System.Data.OleDb.OleDbParameter("address", System.Data.OleDb.OleDbType.VarWChar, 50, "address"),
new System.Data.OleDb.OleDbParameter("ID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((byte)(10)), ((byte)(0)), "ID", System.Data.DataRowVersion.Current, null),
new System.Data.OleDb.OleDbParameter("dnasequence", System.Data.OleDb.OleDbType.VarWChar, 200, "dnasequence")});
//
// oleDbSelectCommand1
//
this.oleDbSelectCommand1.CommandText = "SELECT p-name, address, ID, dnasequence FROM Db";
this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
//
// oleDbUpdateCommand1
//
this.oleDbUpdateCommand1.CommandText = resources.GetString("oleDbUpdateCommand1.CommandText");
this.oleDbUpdateCommand1.Connection = this.oleDbConnection1;
this.oleDbUpdateCommand1.Parameters.AddRange(new System.Data.OleDb.OleDbParameter[] {
new System.Data.OleDb.OleDbParameter("p-name", System.Data.OleDb.OleDbType.VarWChar, 50, "p-name"),
new System.Data.OleDb.OleDbParameter("address", System.Data.OleDb.OleDbType.VarWChar, 50, "address"),
new System.Data.OleDb.OleDbParameter("ID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((byte)(10)), ((byte)(0)), "ID", System.Data.DataRowVersion.Current, null),
new System.Data.OleDb.OleDbParameter("dnasequence", System.Data.OleDb.OleDbType.VarWChar, 200, "dnasequence"),
new System.Data.OleDb.OleDbParameter("Original_ID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((byte)(10)), ((byte)(0)), "ID", System.Data.DataRowVersion.Original, null),
new System.Data.OleDb.OleDbParameter("Original_address", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "address", System.Data.DataRowVersion.Original, null),
new System.Data.OleDb.OleDbParameter("Original_address1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "address", System.Data.DataRowVersion.Original, null),
new System.Data.OleDb.OleDbParameter("Original_dnasequence", System.Data.OleDb.OleDbType.VarWChar, 200, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "dnasequence", System.Data.DataRowVersion.Original, null),
new System.Data.OleDb.OleDbParameter("Original_dnasequence1", System.Data.OleDb.OleDbType.VarWChar, 200, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "dnasequence", System.Data.DataRowVersion.Original, null),
new System.Data.OleDb.OleDbParameter("Original_p-name", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "p-name", System.Data.DataRowVersion.Original, null),
new System.Data.OleDb.OleDbParameter("Original_p-name1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "p-name", System.Data.DataRowVersion.Original, null)});
//
// qurey_label
//
this.qurey_label.******** = new System.Drawing.Point(40, 224);
this.qurey_label.Name = "qurey_label";
this.qurey_label.Size = new System.Drawing.Size(288, 72);
this.qurey_label.TabIndex = 12;
this.qurey_label.Text = "Qurey";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(360, 366);
this.Controls.Add(this.qurey_label);
this.Controls.Add(this.find_btn);
this.Controls.Add(this.del_btn);
this.Controls.Add(this.up_btn);
this.Controls.Add(this.Add_btn);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

}
#endregion

///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void find_btn_Click(object sender, System.EventArgs e)
{
try
{

this.oleDbDataAdapter1.SelectCommand.CommandText =
"SELECT * FROM Db WHERE ID = "+ this.textBox1.Text;

// clear the DataSet from the last operation
dataSet11.Clear();

this.oleDbDataAdapter1.Fill(this.dataSet11.Tables["Db"]);

}
catch(System.Data.OleDb.OleDbException exp)
{
MessageBox.Show(exp.ToString());
}

//copy the dataset in datatable object
DataTable dataTable = dataSet11.Tables[ 0 ];

//if the row count = 0 then the qurey return nothing
if ( dataTable.Rows.Count == 0 )
MessageBox.Show("the Record not founded");
}

private void Add_btn_Click(object sender, System.EventArgs e)
{
try
{
this.oleDbDataAdapter1.InsertCommand.CommandText =
"INSERT INTO Db (p-name, address, ID, dnasequence)" +
"VALUES ('"+ this.textBox3.Text +"','"+this.textBox4.Text+
"' , "+ this.textBox1.Text +",'"+ this.textBox2.Text+ "')";

//open the bridge between the application and the datasource
this.oleDbConnection1.Open();

this.oleDbDataAdapter1.InsertCommand.Connection = oleDbConnection1;

//execute the qurey
this.oleDbDataAdapter1.InsertCommand.ExecuteNonQuery();

//close the connection
this.oleDbConnection1.Close();

MessageBox.Show("Record insedted Successfully"); //inform the user

//clear the form
this.textBox2.Text = "";
this.textBox1.Text = "";
this.textBox3.Text = "";
this.textBox4.Text = "";

//show the qurey
this.qurey_label.Text = "";
this.qurey_label.Text = oleDbDataAdapter1.InsertCommand.CommandText.ToString();

}
catch(System.Data.OleDb.OleDbException exp)
{
//close the connection
this.oleDbConnection1.Close();

MessageBox.Show(exp.ToString());
}


}

private void up_btn_Click(object sender, System.EventArgs e)
{
try
{
this.oleDbDataAdapter1.UpdateCommand.CommandText =
"UPDATE Db SET "+
"p-name ='"+ this.textBox3.Text +"', address ='"+this.textBox4.Text +
"', ID ="+this.textBox1.Text+", dnasequence ='"+ this.textBox2.Text+"'" +
" WHERE ID ="+ this.textBox1.Text;

//open the bridge between the application and the datasource
this.oleDbConnection1.Open();

this.oleDbDataAdapter1.UpdateCommand.Connection = oleDbConnection1;

//execute the qurey
this.oleDbDataAdapter1.UpdateCommand.ExecuteNonQuery();

//close the connection
this.oleDbConnection1.Close();

MessageBox.Show("Record updated Successfully"); //inform the user

//clear the form
this.textBox2.Text = "";
this.textBox1.Text = "";
this.textBox3.Text = "";
this.textBox4.Text = "";

//show the qurey
this.qurey_label.Text = "";
this.qurey_label.Text = oleDbDataAdapter1.UpdateCommand.CommandText.ToString();
}
catch(System.Data.OleDb.OleDbException exp)
{
//close the connection
this.oleDbConnection1.Close();
MessageBox.Show(exp.ToString());
}

}

private void del_btn_Click(object sender, System.EventArgs e)
{
try
{
this.oleDbDataAdapter1.DeleteCommand.CommandText =
"DELETE FROM Db WHERE ID =" + this.textBox1.Text;

//open the bridge between the application and the datasource
this.oleDbConnection1.Open();

this.oleDbDataAdapter1.DeleteCommand.Connection = oleDbConnection1;

//execute the qurey
this.oleDbDataAdapter1.DeleteCommand.ExecuteNonQuery();

//close the connection
this.oleDbConnection1.Close();

MessageBox.Show("Record deleted Successfully"); //inform the user

//clear the form
this.textBox2.Text = "";
this.textBox1.Text = "";
this.textBox3.Text = "";
this.textBox4.Text = "";

//show the qurey
this.qurey_label.Text = "";
this.qurey_label.Text = oleDbDataAdapter1.DeleteCommand.CommandText.ToString();
}
catch(System.Data.OleDb.OleDbException exp)
{
//close the connection
this.oleDbConnection1.Close();

MessageBox.Show(exp.ToString());
}
}


}
}