SQL Server Connection from .NET CF

G

Guest

I am trying to connect to a SQL Server database from my Symbol MC50 handheld
running WM 2003.

I am able to ping the server from my handheld, and yet no matter what I try
I get the error {"Specified SQL server not found: 192.168.2.11\WASPDB"}

I have written a test program that should work on either .NET framwork or
the .NET CF framework. The same code works just fine from my desktop, but
when I run this code from the handheld I get the {Specified SQL server not
found message.}

Sample code below, password changed to protect the innocent.

//////////////////////////////////////////////////////////////////////////////////////

Imports System.Data.SqlClient

Public Class Form1

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim cs As String = "Data Source=192.168.2.11\WASPDB;Initial
Catalog=WaspTrackInventory;User Id=sa;Password=xxxxxxx;persist security
info=False"
Dim dbConn As SqlConnection = New SqlConnection(cs)
Dim da As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM item",
dbConn)
Dim myTable As DataTable = New DataTable

dbConn.Open()
da.Fill(myTable)

TextBox1.Text() = "hello"
TextBox2.Text() = "Count = " + myTable.Rows.Count.ToString()

dbConn.Close()
da.Dispose()

End Sub
End Class

//////////////////////////////////////////////////////////////////////////////////////
 
T

TechGladiator

I dont know why you are typing \WASPDB after the IP address (Never done
it myself) but the code bellow works perfect for me when I connect to a
SQL Server from my Symbol Handheld. I can connect to either SQL 2000
or SQL 2005



Public Function OpenDatabase(ByVal Server As String, ByVal
DatabaseName As String, _
ByVal UserID As String, ByVal Password
As String, _
ByVal DBConnection As SqlConnection)
As Boolean

strConnectString = "Server=" & Server & _
";Database=" & DatabaseName & _
";User Id=" & UserID & _
";Password=" & Password & ";"

DBConnection.ConnectionString = strConnectString

Try
DBConnection.Open()
Return True

Catch ex As Exception
Return False
End Try

End Function


Hope this helps
 
G

Guest

the "\WASPDB" at the end of the server name is a named instance. The database
that I need to access is from packaged software that installs that instance
so I have no control over that.

Regardless, I tried the connection string as you have it and I get the same
results. I can connect from the desktop, but not from the handheld, even
though I can ping the server from the handheld.

Any other thoughts you have will be greatly appreciated.
 
T

TechGladiator

I know this is very basic but I been burned by it before. Do you have
some type of software firewall installed at the server? Is he machine
where you are trying this from(desktop) the SQL Server as well? If
yes, what I would do is I would try to connect from another
machine(desktop) that is not the server.

I know this is very simple stuff but sometimes the obvious is the
hardest thing to find...

Hope this helps.
--Mike
 
G

Guest

No, my development box is seperate from the server and there is no firewall
software on either my box or the server.

I agree with you that the basic stuff is the hardest to detect sometimes,
but when that is the case, there is usually some methodolgy for verifying the
basics.

I have had to debug database connections before and have run into
authentication problems with "SSPI Context" working in a mixed
Domain/Workgroup environment. Those types of connection errors are always
explicit though as the above error happens before the connection itself. That
does not seem to be the case here.

I wish there was some similar way of externally debuging and verifiying the
database connection.

I am suprised though, because your working connection from the handheld does
not include the "persist security info=False" attribute which I was led to
belive was mandetory for handheld connections to SQL Server as they are not
considered part of the domain.

Did you run into any issues when you were setting up, or is there any way
you have had to prep the handhelds. Perhaps I have the wrong version of the
..NET CF SQLClient (I have Version 2)

Regarless, let me thank you for responding, and I hope I can figure this out
soon as I will have to change my architecture (not ideal) to use SQLCE doing
updates to SQL Server through the web server as I am working on a very tight
deadline.
 
T

TechGladiator

My connection definetly doesnt include "Persist Security...." and it
has always worked fine. I am connecting to servers that are both part
of a domain and others that are stand alone servers and never had a
problem with the connect string not including that.

I just thought of something as I was typing this message. Have you
tried connecting to a SQL server with the default instance name? If
you have the ability to test your code without adding the "\WASPDB" at
the end I think you may be in for a surprise.

I didnt have to prep the handhelds with any special things, I just
installed the CF framework and then I just added the SQL client Cab
files to it and it works good. I dont know the version number that I
have (home right now), but whatever version comes with VS2005 is what
got uploaded to my HH..

I would recommend against going the SQLCE way as this may give you more
headaches.

Hope the suggestings above work for you.

--Mike
 
M

Martin Robins

This could still be a firewall or protocol issue. Your desktop application
may be connecting via named pipes instead of TCP/IP - ensure that any
firewalls between the mobile device and the SQL Server have port TCP/1433
and UDP/1434. You may also want to check what port the WASPDB instance is
published on and ensure that port is open also.
 
G

Guest

I am looking into that now. There are definitely no firewall issues and the
server is supporting both named pipes and TCP-IP. How can I verify what my
desktop client is using. I had assumed that since I am connecting to an IP
address, it would use the TCP-IP protocol to connect.

Naturally, assumptions are always dangerous.

The server was supporting named pipes and TCP-IP. I removed named pipes
using the server's client configuration utility,as a protocol and can still
connect with the desktop application. the TCP port was the standard 1433.

Do other instances show up on other ports? And if so, how do you configure
or see these ports?
 
G

Guest

Yes, I have tried connecting to the un-named instance on which I have
installed Northwind. No such luck.

Right now my focus is on getting the problem resolved in the emulator. I
experience the same issues when trying to run this code from the emulator.
When I have it working there, Hopefully it should work from the handheld.

Any ideas on how to proceed?
 
T

TechGladiator

I am all out of things to have you try. Have you tried pinging the
handheld from the server? And viceversa?. Have you tried connecting
using my connect string to the Northwin DB?

--Mike
 

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