Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C# by alen abiye ( 14 years ago )
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace VTDeneme
{
    public partial class Form1 : Form
    {

        OleDbConnection conn = new OleDbConnection("Provider=OraOLEDB.Oracle;Data Source=ORCL;User Id=HASTANE;Password=HASTANE;");
            
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            conn.Open();
            OleDbDataAdapter adapter = new OleDbDataAdapter("select * from hastane.VTDeneme order by id", conn);

            DataSet ds = new DataSet();
            
            adapter.Fill(ds, "TABLO1");
            dataGridView1.DataSource = ds.Tables["TABLO1"];
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
           
           // conn.Open();

            string maxxxid;

            OleDbCommand maxid = new OleDbCommand();
            maxid.Connection = conn;
            maxid.CommandText ="select max(id) from vtdeneme";
            maxxxid = maxid.ExecuteScalar().ToString();
            int number = Convert.ToInt32(maxxxid);
            number++;
            maxxxid = number.ToString();
            DataTable DTMaxid = new DataTable();
            OleDbDataAdapter DAMaxid = new OleDbDataAdapter();
            DAMaxid.SelectCommand = maxid;
            DAMaxid.Fill(DTMaxid);

            OleDbCommand kaydet =  new OleDbCommand();
            kaydet.Connection = conn;
            kaydet.CommandText = "INSERT INTO VTDENEME VALUES ("+ maxxxid +", '" + textBox1.Text + "', '" + textBox2.Text + "', '" + textBox2.Text + "') ";
            kaydet.ExecuteNonQuery();
     
            OleDbDataAdapter adapter = new OleDbDataAdapter("select * from hastane.VTDeneme order by id", conn);
            DataSet ds = new DataSet();

            adapter.Fill(ds, "TABLO1");
            dataGridView1.DataSource = ds.Tables["TABLO1"];
            
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
        
            label4.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
         //   conn.Open();
            
            OleDbCommand sil = new OleDbCommand();
            sil.Connection = conn;
            sil.CommandText = "delete from hastane.vtdeneme where id="+label4.Text;
            sil.ExecuteNonQuery();

            OleDbDataAdapter adapter = new OleDbDataAdapter("select * from hastane.VTDeneme order by id", conn);
            DataSet ds = new DataSet();

            adapter.Fill(ds, "TABLO1");
            dataGridView1.DataSource = ds.Tables["TABLO1"];

        }
    }
}

 

Revise this Paste

Your Name: Code Language: