Archive

Archive for กุมภาพันธ์, 2009

.NET Compact Framework (PDA) ติดต่อ Mssql

กุมภาพันธ์ 6th, 2009

ในการติดต่อกับฐานข้อมูลของ microsoft เอง จะใช้ tools ที่ชื่อว่า Microsoft SQL Server 2005 Mobile Edition Device SDK

download ได้จาก

http://www.microsoft.com/downloads/details.aspx?FamilyID=5bd8abaa-5813-4db3-b23a-24551de2ecc1&displaylang=en

ผมเคยแค่ต่อ db ที่เป็น .sdf บนเครื่อง pda ครับ ยังไม่เคยลอง remote ต่อไปยัง db ที่เป็น ip ท่านใดลองได้แล้ว รบกวนแจ้งวิธีการหน่อยนะครับ

MOBILE

.NET Compact Framework (PDA) ติดต่อ Mysql

กุมภาพันธ์ 5th, 2009

ใช้ connector ที่ Mysql มีมาให้ครับ

http://dev.mysql.com/downloads/connector/net/5.1.html

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Configuration;

namespace MySQLCompact
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
try
{
lBoxResults.Items.Clear();
MySqlConnection connection = new
MySqlConnection(”SERVER=MySQL server IP
address;DATABASE=databaseName;UID=user;PASSWORD=password;pooling=false”);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = “select * from table1″;
connection.Open();
Reader = command.ExecuteReader();
while (Reader.Read())
{
string thisrow = “”;
for (int i = 0; i < Reader.FieldCount; i++)
thisrow += Reader.GetValue(i).ToString() +
lBoxResults.Items.Add(thisrow);
}
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}

MOBILE

แก้ปัญหาต่อ Mysql ด้วย DBDesigner4 ไม่ได้

กุมภาพันธ์ 3rd, 2009

ผมได้ทดสอบใช้ DBDesigner4. แต่เกิด Error ในขั้นตอนการติดต่อ MySql

Connection to database failed.

dbExpress Error: Invalid
Username/Password

แก้ไขโดย

>mysql -u root -p
>SET PASSWORD FOR ‘root’@'localhost’ = OLD_PASSWORD(’r00tp45sw0rd’);
>UPDATE mysql.user SET Password = OLD_PASSWORD(’r00tp45sw0rd’) WHERE Host = ‘localhost’ AND User = ‘root’;
>FLUSH PRIVILEGES;

OpenSource