C Access
C Access
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;
using System.Data.SqlClient;
namespace wnd_form1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection baglantiyolu = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=uyg1.mdb");
DataSet ds = new DataSet();
OleDbDataAdapter adtr = new OleDbDataAdapter();
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;
using MySql.Data.MySqlClient;
namespace wnd_form1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
insert
string constring="datasource=localhost;port=3306;username=root;password=root";
string Query="insert into database.edata(Eid,name,surname,age) values(‘" + this.Eid_txt.Text + "’ ,‘" +
this.Name_txt.Text + "’ , ‘" + this.Surname_txt.Text + "’ , ‘" + this.Age_txt.Text + "’ ); " ;
MySqlConnection conDataBase=new MySqlConnection(constring);
MySqlCommand cmdDatabase=new MySqlCommand(Query, conDataBase);
MySqlDataReader myReader;
try {
conDataBase.Open();
myReader=cmdDataBase.ExecuteReader();
MessageBox.Show("Saved");
while(myReader.Read()){
} catch(Exception ex) {
MessageBox.Show(ex.Message);
}
Update
string constring="datasource=localhost;port=3306;username=root;password=root";
string Query="update database.edata set Eid=‘" + this.Eid_txt.Text + "’ ,name=‘" + this.Name_txt.Text + "’ ,
surname=‘" + this.Surname_txt.Text + "’ , age=‘" + this.Age_txt.Text + "’ where Eid= ‘" + this.Eid_txt.Text + "’ ; " ;
MySqlConnection conDataBase=new MySqlConnection(constring);
MySqlCommand cmdDatabase=new MySqlCommand(Query, conDataBase);
MySqlDataReader myReader;
try {
conDataBase.Open();
myReader=cmdDataBase.ExecuteReader();
MessageBox.Show("Saved");
while(myReader.Read()){
} catch(Exception ex) {
MessageBox.Show(ex.Message);
}
Delete
string constring="datasource=localhost;port=3306;username=root;password=root";
string Query="delete from database.edata where Eid=‘" + this.Eid_txt.Text + "’ ; " ;
MySqlConnection conDataBase=new MySqlConnection(constring);
MySqlCommand cmdDatabase=new MySqlCommand(Query, conDataBase);
MySqlDataReader myReader;
try {
conDataBase.Open();
myReader=cmdDataBase.ExecuteReader();
MessageBox.Show("Updated");
while(myReader.Read()){
} catch(Exception ex) {
MessageBox.Show(ex.Message);
}
protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);
Graphics g = CreateGraphics();
Pen p=new Pen(Color.White);
Pen p1 = new Pen(Color.Red);
Pen p2 = new Pen(Color.Green);
Pen p3 = new Pen(Color.Blue);
Pen p4 = new Pen(Color.Yellow);
comboBox2.Text = "Daire";
comboBox2.Items.Add("Daire");
comboBox2.Items.Add("Kare");
comboBox2.Items.Add("Elips");
comboBox2.Items.Add("Dikdörtgen");
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
renk = comboBox1.Text;
label1.Text = renk;
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
sekil = comboBox2.Text;
label2.Text = sekil;
}
private void button1_Click(object sender, EventArgs e)
{
Form2 goster = new Form2();
goster.Show();
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}