วันจันทร์ที่ 2 มิถุนายน พ.ศ. 2551

วิธีการติดต่อฐานข้อมูลโดยใช้ SharpDevelop

1. ก่อนอื่นต้อง Download MySql Connector มาก่อน
2. หลังจากติดตั้งเสร็จแล้ว ให้เรา Add Reference ลงใน Project ของเราโดยเลือก
Project->AddReference->GAC->MySQL->Select

3. เพิ่ม Code ลง "using Mysql.Data.MySqlClient;" ลงในส่วน using

ตัวอย่าง Code


using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace TestDatabase
{
///
/// Description of MainForm.
///

public partial class MainForm : Form
{
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void Button1Click(object sender, EventArgs e)
{
string MyConString = "SERVER=localhost;" +
"DATABASE=test;" +
"UID=root;" +
"PASSWORD=;";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = "select * from test";
connection.Open();
Reader = command.ExecuteReader();
while (Reader.Read())
{
string thisrow = "";
for(int i= 0;ithisrow+=Reader.GetValue(i).ToString() + ",";
listBox1.Items.Add(thisrow);
}
connection.Close();
}
}
}

วันพุธที่ 28 พฤษภาคม พ.ศ. 2551

การติดตั้ง wireless intel รุ่น 2200BG, 2300BG บน FreeBSD รุ่น 6.3

1. ติดตั้ง firmware iwi ผ่านทาง Ports

# cd /usr/ports/net/iwi-firmware-kmod/
# make install clean

หมายเหตุ หากมี error ฟ้อง ประมาณว่าไม่เจอ tree ของ Kernel ให้ทำการติดตั้ง Source Code ของ FreeBSD รุ่นนั้นก่อน

2. ทดสอบ Load driver

# kldload -v if_iwi

แล้วลองเรียกคำสั่ง

# dmesg grep iwi

ถ้าทุกอย่างถูกต้อง ผลที่ได้ควรจะมีลักษณะอย่างนี้

iwi0: mem 0xe0206000-0xe0206fff irq 11 at device 4.0 on pci2 iwi0: Ethernet address: xx:xx:xx:xx:xx:xx

3. กำหนดให้ระบบ load driver ในขณะิ boot โดยเพิ่มข้อมูลลงในไฟล์ /boot/loader.conf ดังนี้

if_iwi_load="YES"
wlan_load="YES"
firmware_load="YES"

4. กำหนดให้ wireless เริ่มทำงานโดยเพิ่มข้อมูลลงในไฟล์ /etc/rc.conf ดังนี้

ifconfig_iwi0="ssid testwlan wepmode on wepkey 0x12345678901234567890123456 weptxkey 1 wepmode on DHCP"

ตัวอย่างข้างต้นเป็นการกำหนด ค่าของระบบ wireless ที่มี ssid ชื่อ "testwlan" และมีการเข้ารหัสแบบ WEP โดยใช้ key "12345678901234567890123456" ซึ่งเป็น key ที่ 1 และสุดท้ายเป็นการระบุให้ทำการสอบถามหมายเลข IP จาก DHCP

แหล่งข้อมูลอ้างอิง:
1) http://damien.bergamini.free.fr/ipw/iwi-freebsd.html
2) man iwi (สามารถใช้ได้หลังจากติดตั้ง firmware ในข้อ 1 เสร็จแล้ว)
3) freebsd document ใน Handbook หัวข้อที่ 29 Wireless Networking

Tip:
1) หลังจากติดตั้ง iwi-firmware แล้ว สามารถทำการค้นหา ssid บริเวณนั้นได้โดยใช้คำสั่ง
# ifconfig iwi0 scan

2) หากต้องการเิริ่มระบบ network ใหม่โดยไม่ต้อง boot ระบบ ใช้คำสั่งดังนี้
# /etc/rc.d/netif restart