นี้เปัน Class Class_Conn เปัน Class ที่ใช้ connect BD Code (C#)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.OleDb;
namespace ProjectConn
{
class ClassConn
{
public static OleDbConnection conn = null;
public void Conn_Toay()
{
conn = new OleDbConnection("Provider=MSDAORA; Data Source=XE; User ID=hr; Password=hr; Unicode=True");
conn.Open();
}
}
}
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 System.Data.OleDb;
using System.Data.OracleClient;
namespace ProjectConn
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ClassConn NewConn = new ClassConn();
NewConn.Conn_Toay();
OleDbCommand comm = new OleDbCommand();
comm.Connection = ClassConn.conn;
comm.CommandText= "insert into Testing (name) values (@name)";
comm.Parameters.AddWithValue("@name", textBox1.Text);
comm.ExecuteNonQuery();
}
}
}