Remote DB connection?

T

Tomer

Hi,
I'm trying to connect my pocket pc app to a pc sql server.

I use this connection code:
Conn = new SqlCeConnection("server=P1000; user id=ss; password=; initial
catalog=DBTest");
Conn.Open();

But I get the error:

'Unknown connection option in connection string: server.'

Any thoughts?
 
K

Kevin Hutchison

The connection class you are creating is for SQL Server CE connections only.
Try using System.Data.SqlClient classes.

Good luck,

- K.
 
T

Tomer

Hi,
Well I've tried using those classes, but now I get when I try to open a
connection, this exception:
'PlatformNotSupportedException'
The running code is:
Conn = new SqlConnection("server=P1000; user id=sa; password=sa; initial
catalog=TestDB");

Conn.Open();

I'm running the application on a symbol 2846/8100 that has ppc 2002.

What should I do?
 
M

Me

You may want make sure that you have at least service pack 3 for SQL Server
2000.
Go to
http://support.microsoft.com/default.aspx?sd=tech&scid=kb;EN-US;q321185 for
information of how to identify your sql server pack version and edition. At
end of the article is info on how to get the latest service pack.

I'm not sure if this will help you, but this is what worked for me on the
PPC 2003 iPAQ 4350:

Imports System.Data
Imports System.Data.SqlClient

Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu

Private Sub btnDisplayData_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnDisplayData.Click

Dim ds As New DataSet
Dim strCn As String = "Server=MyServer;Database=Northwind;" & _
"User Id=sa;Password="
Dim sqlConn As SqlConnection
Dim sqlDA As New SqlDataAdapter

Try
sqlConn = New SqlConnection(strCn)
sqlConn.Open()
MessageBox.Show("ServerVersion: " & sqlConn.ServerVersion &
ControlChars.Cr & _
"State: " & sqlConn.State.ToString())
sqlDA = New SqlDataAdapter("SELECT * FROM Customers", sqlConn)
sqlDA.Fill(ds)

'Display the table.
DataGrid1.DataSource = ds.Tables(0)

Catch errSql As SqlException
DisplaySqlErrors(errSql)
End Try
sqlConn.Close()


End Sub

Sub DisplaySqlErrors(ByVal myException As SqlException)
Dim i As Int32
For i = 0 To myException.Errors.Count
MessageBox.Show("Index # " & i & _
"Error: " & myException.Errors(i).ToString())
Next
End Sub

Sub FillError(ByVal sender As Object, ByVal args As FillErrorEventArgs)
If args.Errors.GetType() Is Type.GetType("System.OverflowException")
Then
' Code to handle Precision Loss

args.Continue = True
End If
End Sub


End Class

I hope that this helps.


Gigi

Tomer said:
Hi,
Well I've tried using those classes, but now I get when I try to open a
connection, this exception:
'PlatformNotSupportedException'
The running code is:
Dim strCn As String = "Server=MYSERVER;Database=Northwind;" & _
"User Id=sa;Password="

Dim sqlConn As SqlConnection
sqlConn = New SqlConnection(strCn);
 

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