|
|
|
DataGridView มันจะดึงฐานข้อมูล Database มาโชในตาราง ต้องทำยังงัยบ้างครับขอโค๊ดหน่อยครับ |
|
|
|
|
|
|
|
Code (C#)
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 MySql.Data.MySqlClient;
namespace WindowsFormsApplication1
{
public partial class FormHome : Form
{
MySqlConnection objConn;
MySqlCommand objCmd;
String strSQL;
public FormHome()
{
InitializeComponent();
}
private void FormHome_Load(object sender, EventArgs e)
{
String strConnString;
strConnString = "Server=localhost;User Id=root; Password=123123; Database=db_project; Pooling=false";
objConn = new MySqlConnection(strConnString);
objConn.Open();
DataGridView dgView = new DataGridView();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
FormAdd f = new FormAdd();
f.Show();
}
private void button2_Click(object sender, EventArgs e)
{
this.Hide();
FormAdd f = new FormAdd();
f.Show();
}
private void button3_Click(object sender, EventArgs e)
{
this.Hide();
FormAdd f = new FormAdd();
f.Show();
}
private void button4_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you sure to exit?", "Confirm.", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{
Application.Exit();
}
}
private void button1_Click_1(object sender, EventArgs e)
{
this.Hide();
FormAdd f = new FormAdd();
f.Show();
}
}
}
Tag : .NET, MySQL, C#, VS 2008 (.NET 3.x), VS 2010 (.NET 4.x)
|
|
|
|
|
|
Date :
2011-07-05 10:12:36 |
By :
noi014 |
View :
1447 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (C#)
OleDbConnection objConn = default(OleDbConnection);
OleDbDataAdapter dtAdapter = default(OleDbDataAdapter);
DataTable dt = new DataTable();
string strConnString = null;
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=mydatabase.mdb";
objConn = new OleDbConnection(strConnString);
objConn.Open();
string strSQL = null;
strSQL = "SELECT * FROM customer";
dtAdapter = new OleDbDataAdapter(strSQL, objConn);
dtAdapter.Fill(dt);
dtAdapter = null;
objConn.Close();
objConn = null;
this.myDgv.DataSource = dt;
Go to : (C#) .NET Windows Form Application เขียนโปรแกรมบน Windows Form Application ด้วย .NET Framework
|
|
|
|
|
Date :
2011-07-05 11:35:04 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|