Can't connect to sql 2000 from WinCe 4.1

G

Guest

I have device Symbol MK1000 with wince 4.1 and sql 2000 on desktop.
I need get some data from sql 2000.
Where is class.
Imports System.Data
Imports System.Data.SqlClient

Public Class Sql
Public Function GetPublishersDS() As DataSet
Dim ds As New DataSet
Dim strCn As String = "Server=11.0.3.76;Database=pubs;" & _
"Integrated Security=SSPI;User Id=COMP/test;Password=test"
Try
Dim sqlConn As New SqlConnection(strCn)
sqlConn.Open()
Dim sqlDA As New SqlDataAdapter("SELECT * FROM authors", sqlConn)
sqlDA.Fill(ds)
sqlConn.Close()
Return ds
Catch ex As Exception
ErrTrap(ex)
End Try
End Function

Public Function GetPublishersDS1() As DataSet
Dim ds As New DataSet
Dim strCn As String = "Server=11.0.3.76;Database=pubs;" & _
"Integrated Security=SSPI;UID=sa;Password=sa"
Dim str1 As String
Try
Dim sqlConn As New SqlConnection(strCn)
sqlConn.Open()

Dim sqlDA As New SqlDataAdapter("SELECT * FROM authors", sqlConn)

sqlDA.Fill(ds)
sqlConn.Close()

Return ds
Catch ex As SqlException
Dim e As SqlClient.SqlError
For Each e In ex.Errors
str1 = str1 & vbCrLf & e.Message
Next
MsgBox(str1)
Catch ex As Exception
ErrTrap(ex)
End Try
End Function

Public Function GetPublishersDS2() As DataSet
Dim ds As New DataSet
Dim strCn As String

strCn = "data source=11.0.3.76;" & _
"initial catalog=pubs;" & _
"user id=sa;" & _
"pwd=sa;" & _
"workstation id=COMP;" & _
"packet size=4096;" & _
"persist security info=False;"
Dim str1 As String
Try
Dim sqlConn As New SqlConnection(strCn)
sqlConn.Open()

Dim sqlDA As New SqlDataAdapter("SELECT * FROM authors", sqlConn)

sqlDA.Fill(ds)
sqlConn.Close()

Return ds
Catch ex As SqlException
Dim e As SqlClient.SqlError
For Each e In ex.Errors
str1 = str1 & vbCrLf & e.Message
Next
MsgBox(str1)
Catch ex As Exception
ErrTrap(ex)
End Try
End Function
End Class

I call methods from form on emulator and real device, but get
PlatformNotSupportedException.
The same code work fine on PocketPC.!!!
What to do?
 
I

Ilya Tumanov [MS]

That usually means you're trying to retrieve strings in locale which is not
supported by this particular device.

That might happen if you keep none-Unicode strings in the database.

You can either get rid of these strings, use the device which supports this
locale or switch to Unicode.



Best regards,


Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
A

alur

Thanks for reply.
I create 3 new databases (Northwind) with collations
(Latin1_General_CI_AS, Latin1_General_CI_AI, Latin1_General_CS_AS)
Now i can connect to database, but can't get information.
When i make calls, I ger error NullReferenceException.
What to do?
I don't have any ideas.

Public Function GetDsByConnect(ByVal con As SqlConnection) As DataSet
Dim str1 As String
Dim ds As DataSet
Try
ds = New DataSet
Dim sqlDA As New SqlDataAdapter("SELECT * FROM Orders",
con)

sqlDA.Fill(ds)'Error throws where
con.Close()

Return ds
Catch ex As SqlException
Dim e As SqlClient.SqlError
For Each e In ex.Errors
str1 = str1 & vbCrLf & e.Message
Next
MsgBox(str1)
Catch ex As Exception
ErrTrap(ex)

End Try
End Function

Public Function GetRdByConnect(ByVal con As SqlConnection) As
SqlDataReader
Dim str1 As String
Try
Dim com As SqlCommand
If con Is Nothing Then
Return Nothing
End If
If con.State <> ConnectionState.Open Then
Return Nothing
End If
Dim rd As SqlDataReader
com = con.CreateCommand()
com.CommandType = CommandType.Text
com.CommandText = "select * from Orders"
rd = com.ExecuteReader(CommandBehavior.SingleResult)'Error
throws where
rd.Close()
While rd.Read
MsgBox(rd.GetSqlString(0))
End While
Catch ex As SqlException
Dim e As SqlClient.SqlError
For Each e In ex.Errors
str1 = str1 & vbCrLf & e.Message
Next
MsgBox(str1)
Catch ex As Exception
ErrTrap(ex)
End Try
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top