 |
|
สอบถามเกี่ยวกับ Windows CE Connect Database ได้วิธีไหนได้มั่ง |
|
 |
|
|
 |
 |
|
รบกวนสอบถามครับว่า
มีวิธีการไหนบ้างครับ ที่สามารถให้ Windows CE ติดต่อกับฐานข้อมูล SQL Server ได้บ้างครับ โดยจะใช้ VB.net ในการเขียน Code ครับ
ผมได้ลอง เขียน Code โดยตรงเพื่อติดต่อกับฐานข้อมูล แต่ก็ขึ้น [font=Verdana]error ตามนี้ครับ login failed for user ' '. the user is not associated with a trusted sql server connection[/font]
Code (VB.NET)
Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClient
Imports System.Data.SqlServerCe
Public Class Form1
' Private conStr As String = "Data Source=192.168.0.188,1433;Initial Catalog=dbEmployee;Integrated Security=True;uid=sa; pwd=******; "
Private conStr As String = "Data Source=192.168.X.XX;Initial Catalog=iERP81_T1;Integrated Security=True;uid=sa; pwd=******; "
Private mycon As SqlConnection
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
mycon = New SqlConnection(conStr)
If mycon.State = ConnectionState.Closed Then
mycon.Open()
End If
' Catch ex As Exception
' MsgBox("Invalid connectionString")
Catch ex As SqlException
Dim l_sqlerr As SqlError
For Each l_sqlerr In ex.Errors
MsgBox(l_sqlerr.Message)
Next
End Try
End Sub
Sub template()
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Try
With cmd
.Connection = mycon
.CommandType = CommandType.Text
.CommandText = ""
End With
da.SelectCommand = cmd
da.Fill(ds, "")
Catch exsql As SqlException
MsgBox(exsql.Message, MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
Private Sub ShowDetail()
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim ds As New DataSet
'Dim dr As New SqlDataReader
Try
With cmd
.Connection = mycon
.CommandType = CommandType.Text
'.CommandText = "select top 1 * from employee order by newid()"
' .CommandText = "select itc_id from itc"
.CommandText = "select IMA_ItemID from Item"
End With
da.SelectCommand = cmd
da.Fill(ds, "Show") 'Keep data to Dataset
dgShow.DataSource = ds.Tables("Show")
Catch exsql As SqlException
MsgBox(exsql.Message, MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click
ShowDetail()
End Sub
End Class
Code error fy
ขอบคุณครับ
Tag : .NET, Ms SQL Server 2005, VB.NET
|
|
 |
 |
 |
 |
Date :
2013-03-14 11:01:39 |
By :
s_oil_p |
View :
4447 |
Reply :
17 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่น่าจะได้น่ะครับ คิดว่าน่าจะได้เฉพาะ Database ในเครื่อง Local ครับ 
|
 |
 |
 |
 |
Date :
2013-03-14 11:04:25 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำไมไม่ได้ครับ แล้วมีวิธีการอื่นหรือเปล่าครับ
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2013-03-14 11:08:46 |
By :
s_oil_p |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้ web service แทนครับ
|
 |
 |
 |
 |
Date :
2013-03-15 10:19:51 |
By :
Nameless |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตามนั้นครับ แนะนำให้ใช้ผ่านพวก Web Service ครับ
|
 |
 |
 |
 |
Date :
2013-03-15 10:35:48 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณสำหรับทุกคำตอบครับ
การเขียน ผ่าน Web Service เราต้องเริ่มต้นอย่างไรครับ พอมีตัวอย่างหรือเปล่าครับ
|
 |
 |
 |
 |
Date :
2013-03-15 12:57:32 |
By :
s_oil_p |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
.NET and Web Service การสร้างและเรียกใช้งาน Web Service บน .NET Framework
อ่านครับ
|
 |
 |
 |
 |
Date :
2013-03-15 13:52:34 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอนนี้ทำได้แล้วนะครับ
โดยวิธีดังนี้
ให้ Copy file dbnetlib.dll ไปไว้ที่ Nandflash บน ARM11 เพราะขณะที่เรา Run Program จาก VB.net ไฟล์ตัวนี้ จะรัน อยู่ที่ Windows ของ Board Arm11 เมื่อเราปิด Board แล้วเปิดใหม่ ค่าใน Windows จะกลับมาเป็นค่า ปกติ ของ Windows Ce ครับ
ขอบคุณสำหรับทุกคำตอบนะครับ
|
 |
 |
 |
 |
Date :
2013-03-23 16:23:47 |
By :
s_oil_p |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เยี่ยมไปเลยครับ
|
 |
 |
 |
 |
Date :
2013-03-23 16:36:03 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยอธิบาย ให้ละเอียดได้ไหมครับ... คุณ oil
Copy file dbnetlib.dll ไปไว้ที่ Nandflash บน ARM11
ไม่ทราบว่า Nandflash คือ อะไรครับ แล้วก็ ARM11 คืออะไรครับ
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2013-05-14 17:09:02 |
By :
text_292 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง PM ไปถามดูน่ะครับ 
|
 |
 |
 |
 |
Date :
2013-05-14 17:41:31 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณ Text ครับ
เดี๋ยวผมอธิบายให้ฟังครับ
พอดีผมได้ซื้อ Borad ARM 11 มา ให้เจ้า Board ARM 11 (mini6410) นี้ เขาได้ลง Windows CE ไว้ แต่เมื่อเราปิดเครื่องแล้วเปิดใหม่ข้อมูลที่เราเก็บไว้ถ้าเราไม่ได้นำไปไว้ ที่ Nanflash ข้อมูลก็จะหาย ครับ
Board ARM สามารถดูข้อมูลเพิ่มเติมได้ที่ http://www.thaieasyelec.com/index.php?lay=show&ac=webboard&WBntype=3
|
 |
 |
 |
 |
Date :
2013-05-15 16:15:37 |
By :
s_oil_p |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จัดไปครับ
|
 |
 |
 |
 |
Date :
2013-05-16 06:27:06 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ่อ ขอบคุณครับ
ว่าแต่ เอ ตอนนี้ผมตกม้าตายตรงที่ การ Connect SQL Server 2008 ครับ
ผมดันเจอปัญหาเดียวกับ เจ้าของกระทู้นี้ครับ >> https://www.thaicreate.com/dotnet/forum/078417.html
เลยใช้วิธีการ ให้ชี้ไปที่ WebService แทนครับ อันนี้ connect DataBase ได้ปกติ
แต่ถ้าอ้างอิงแบบ Private conStr As String = "server=192.168.X.XXX;uid=sa;pwd=XXXXXX;database=XXXXXX;"
ตอนโหลด Form ใช้งานไม่ได้ครับ หรือเป็นเพราะผมทดสอบโปรเจค ด้วย Pocket PC 2003 SE Emulator กันครับ
แต่ก็เซ็ตให้ ตัว Emulator ได้ IP แล้วน่ะครับ ข้างนอก ping เจอเจ้านี้ Emulator แล้วด้วย ยังงงอยู่เลยครับ
ถ้าท่านใดมีประสบการณ์ ผมขอคำปรึกษาหน่อยครับ
|
 |
 |
 |
 |
Date :
2013-05-16 11:39:54 |
By :
text_292 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClient
Imports System.Data.SqlServerCe
Public Class Form1
Private conStr As String = "server=192.168.0.23;uid=sa;pwd=xxxx;database=xxxx;"
Private mycon As SqlConnection
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
mycon = New SqlConnection(conStr)
If mycon.State = ConnectionState.Closed Then
mycon.Open()
End If
' Catch ex As Exception
' MsgBox("Invalid connectionString")
Catch ex As SqlException
Dim l_sqlerr As SqlError
For Each l_sqlerr In ex.Errors
MsgBox(l_sqlerr.Message)
Next
End Try
End Sub
Sub template()
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Try
With cmd
.Connection = mycon
.CommandType = CommandType.Text
.CommandText = ""
End With
da.SelectCommand = cmd
da.Fill(ds, "")
Catch exsql As SqlException
MsgBox(exsql.Message, MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
Private Sub ShowDetail()
Dim cmd As New SqlCommand
Dim da As New SqlDataAdapter
Dim ds As New DataSet
'Dim dr As New SqlDataReader
Try
With cmd
.Connection = mycon
.CommandType = CommandType.Text
'.CommandText = "select top 1 * from employee order by newid()"
' .CommandText = "select itc_id from itc"
.CommandText = "select * from Tape"
End With
da.SelectCommand = cmd
da.Fill(ds, "Show") 'Keep data to Dataset
dgShow.DataSource = ds.Tables("Show")
Catch exsql As SqlException
MsgBox(exsql.Message, MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click
ShowDetail()
End Sub
End Class
ด้านบน เป็น Code โชว์ข้อมูลธรรมดา เมื่อเรา connect sqlServer2005 เมื่อผมลองรันที่ตัว Board ARM 11 รันได้ปกติ แต่ใน Pocket PC 2003 SE Emulator ยังไม่เคยลองครับ เดี๋ยวผมจะลองดูเหมือนกัน เดี๋ยวคุณ TEXT ลองดู ว่า Code ของผมเหมือนคุณ TEXT หรือเปล่า
ถ้าได้ยังไงรบกวนแจ้งด้วยครับ
|
 |
 |
 |
 |
Date :
2013-05-16 16:34:48 |
By :
s_oil_p |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณ oil Code ที่ผมเขียนก็ประมาณนี้ล่ะครับ
แต่ก็ยังติดเหมือนเดิมครับ PlatformNotSupportedException ครับ
แต่ตอนนี้ยังไม่มีเวลาเข้าไปแก้ปัญหาครับ
แต่ได้ ข้อสรุปจากการค้นหาข้อมูลเบื้องต้นแล้วครับ
1. เปลี่ยนจาก collation ของ database ให้เป็น latin-bin (เดิมของผมใช้ thai-bin)
2. ลง Sql Server sp3 ขึ้นไป
3. กลับมาใช้ WebService เหมือนเดิม
ขอบคุณมากครับ คุณ oil
|
 |
 |
 |
 |
Date :
2013-05-17 10:12:50 |
By :
text_292 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้โดยวิธีการเปลี่ยนจาก collation ของ database ถูกต้องแล้วครับ แต่จะต้องกำหนด collation ตอน select ข้อมูลครับ
เช่น
Code (SQL)
select name=name COLLATE Latin1_General_CI_AS from Account where Username ='admin'
|
ประวัติการแก้ไข 2013-05-17 10:55:28
 |
 |
 |
 |
Date :
2013-05-17 10:54:27 |
By :
ajmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|