How can I connect to sql server from a mobile device?
the server is on pc and my app is on the device.
I want to perform commands and stored procedures which will be performed online on the pc and get immediate results.
is there any way of achiving that?
Once this is done its the same as if you were connecting to sqlserver on the full framework with ASP.net or VB.net
here is some sample code
Imports System.Data.Common
Imports System.Data.SqlClient
Private m_connString As String = "user id=sa;password=;initial catalog=Northwind;Server=xxx.xxx.xxx.xxx;"
Private m_ds As New DataSet
Dim l_sqlConn As SqlConnection
Dim l_da As DataAdapter
Dim l_ds As DataSet
Dim l_sqlStmt As String
Try
l_sqlConn = New SqlConnection(m_connString)
l_sqlConn.Open()
l_sqlStmt = "SELECT * FROM tbl_Users ORDER BY FullName"
l_da = New SqlDataAdapter(l_sqlStmt, l_sqlConn)
m_ds = New DataSet
l_da.Fill(m_ds)
Catch ex As SqlException
Dim l_sqlerr As SqlError
For Each l_sqlerr In ex.Errors
MsgBox(l_sqlerr.Message)
Next
Finally
If l_sqlConn.State = ConnectionState.Open Then
l_sqlConn.Close()
l_sqlConn = Nothing
End If
End Try
Dim l_cmd As SqlCommand = l_sqlConn.CreateCommand()
l_cmd.CommandType = CommandType.StoredProcedure
l_cmd.CommandText = "<Stored Procedure Name>"
l_cmd.Parameters.Add(New SqlParameter("UnitOutDate", SqlDbType.DateTime))
l_cmd.Parameters("UnitOutDate").Value = Date.Now
l_cmd.executeNonQuery()
when i try to open the connection i get a "PlatformNotSupportedException"
is there any reason that exception could appears?|||on the emulator or on the device|||
let me specify a little:
I have a device which has a microsoft windows ce .net version 4.2 system.
i try to connect it to sqlserver 2000 that is on a pc server(win 2000 for servers). I create SqlConnect object on the device with the connection string
"Persist Security Info=False;Integrated Security=false; database=northwind; server=xxx.xxx.xxx.xxx; Connect Timeout=30; User ID=testing; Password=test;"
so far so good, but when i perform the function Open(on the device itself), I get the "PlatformNotSupportedException".
and i just cannot figure out why.
Try testing it on the emulator and see if you get the same error|||
That usually means DB collation you're using is not supported on particular device. You can change collation of this DB or get localized device which supports locale you’re using.
I created another database on the same server and gave it's collation Latin1_General_CI_AS and tried again and it worked :-)
which brings me to this question:
is there any way to tell the connection object what the database collation is? because I dont think i'm allowed to convert the database to Latin1_General_CI_AS collation.
or any other way to solve this mess...|||you can specify the locale identifier in the connection string.
see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlservercesqlceconnectionclassconnectionstringtopic.asp
-Darren Shaffer
.NET Compact Framework MVP|||
Darren Shaffer wrote:
you can specify the locale identifier in the connection string.
see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqlservercesqlceconnectionclassconnectionstringtopic.asp-Darren Shaffer
.NET Compact Framework MVP
I have this same problem (platformnotsupported) and I don't understand your answer. Problem is with SqlConnection and you say that we must add locale identifier in connection string to SqlCeConnection?
|||
As you correctly noted this is not going to work with SQL Client as it’s about SQL CE. So you have two choices:
1. Change database collation to something which is supported on device.
2. Get device which supports your database collation.
|||
Ilya Tumanov wrote:
As you correctly noted this is not going to work with SQL Client as it’s about SQL CE. So you have two choices:
1. Change database collation to something which is supported on device.
2. Get device which supports your database collation.
I know
Ad 1. No, i can't change collation of my database.
Ad.2. I can't get device which support my database collation (it is Symbol MC9090 with Win CE 5.0 and my database have Polish_CI_AS collation). Works great when I change colllation to Latin1_general but i can't do this with my main database.
Is there an other option? I try RDA but problem with charsets exists, Polish chars ? ? ? ń etc. changes to strange symbols, its useless.
No comments:
Post a Comment