作者clubflymf (clubfly)
看板PHP
標題Re: [請益] PC 回傳資料 給PDA 的方法
時間Thu Jun 11 10:04:05 2009
所以您是想直接 使用 pda 連線 mysql 是嗎? @@
這個 是嵌入式系統了吧 XD
MYSQL 有提供資料庫的 Connectors
有 odbc, jdbc, net, mxj, c++, c, native driver for php
看您想使用那一種 語言寫 就去參考用那一種連線..
pda + net + c# 的話(vb也ok 要改一下下)
之前有看到一個方式
dreamtails 提供的
很方便
也可以學習 c# ..@@
加入 MySql.Data.CF.dll 檔
程式加入 using Mysql.Data.MySqlClient;
//這是 pda 連 mysql 查詢 按鈕點出 就 seach mysql 資料庫
private void Button_Ckick(object sender,EventArgs e){
//設定mysql ip 可自行設定
string DataSource = "localhost";
//設定database name
string Database = "database_name";
//登入id
string UserID = "root";
//登入密碼
string Password = "123";
string myConnectionString = "Data Source=" + DataSource + ";
Database="+Database + ";
UserID = "+UserID +";
Password = " + Password;
MySqlConnection myConnection = new MySqlConnection(MySqlConnectionString);
//設定 sql語法
MySqlCommand myCommand = new MysqlCommand("select * from table1",myConnection);
myConnection.Open();
myReader = myCommand.ExcuteReader();//執行sql
try{
searchTextBox.Text = String.Empty;
while ( myReader.Read() ){
// 0為資料庫第一個欄位資料 1為第二個 以此類推
serchTextBox.Text += myReader.GetDtring(0)+":"+myReader.GetString(1)+"\r\n";
}
}
finally {
myReader.Close();
myConnection.Close();
}
}
//新增 修改 刪除 也類似
privare void Button_Click(object sender,EventArgs e){
//設定mysql資料庫 ip 以localhost 來看
string DataSource = "localhost";
//設定 資料庫名稱
string Database = "database_name";
string UserID = "root";
string Password = "123";
string myConnectionString = "Dada Source="+DataSource+";
Database = "+Database+";
UserID="+UserID+";
Password = "+Password;
MySqlConnection myConnection = new MySqlConnection(myConnectionString);
//看要使用 新增 修改 刪除 ? 取消 // 就可以了
//新增
//string sql = "insert into table set id = id, tel=0968678678 ";
//修改
//string sql = "update table set id =id2 where id='id' ";
//刪除
//string sql = "delete from table where id = 'id' ";
MySqlCommand myCommand = new MySqlCommand(sql);
myCommand.Connection = myConnection;
myConnection.Open();
myCommand.ExcuteNonQuery();
myCommand.Connection.Close();
}
這只是簡單的 c# 用法
其實蠻簡單的...
提供您參考嚕
※ 引述《sct830 (sct830)》之銘言:
: 先敘述一下 目前小弟的狀況
: 因為是新手 第一次PO文 如果有問題 請各位前輩告知 謝謝~
: 目前能做到的功能 是將手機資料 透過HTTP的request
: 傳送給寫在AppSserv下的 .php程式 將所收到的程式 寫入資料庫
: 但是 想要回傳資料庫裡的資料給PDA 要怎麼做呢?
: 小弟目前有想到兩個方法:
: 其一: PDA 透過瀏覽器 去瀏覽寫好的程式(比較不想這樣做)
: 其二: 是想要透過手機傳給 .php程式時 所建立的那個資料流
: 想透過那個資料流還回傳資料給PDA
: 但是 我不知道該怎麼存取那個資料流的資料...
: 或者 有其他的方法可以回傳資料給手機的話
: 請各位前輩者 能給小弟一點方向 或者一些資訊
: 如果有敘述錯誤 也希望能給予指正!! 感激不盡!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.32.116.173
※ 編輯: clubflymf 來自: 114.32.116.173 (06/11 10:08)
推 sct830 :謝謝你的回答~^^ 但主要還是想要有client-server的 06/11 18:46
→ sct830 :架構 提共那部份的文件是有看過了~還是謝謝 06/11 18:47