Help needed for connecting SQl server from PPC Emulator

R

Ramesh Singhvi

I wanted some help with connecting to sql server from Pocket PC 2002
emulator.
I recently upgraded to VS.NET 2003 professional and I am working on a
stand alone(windows form) pocket pc app.
I have SQL server 2000 on my desktop PC and SQL instance is registered
as 'RAMESH\RAMESHSQL'.
When I am trying to connect this sql server from a smartdevice app
thro the emulator I am getting a "SqlException" error. I also tried
putting the port number 1433 in the
Connection string but still no difference. My connection string looks
like "server=RAMESH\RAMESHSQL, 1433;Databse=Pubs;User ID=sa". I was
able to connect to connect to the server from my desktop. Any help
would be really appreciated
 
L

Lloyd Dupont

watch for the error message in the debuger.
SqlException.ToString() always return "SqlException" because Message was not
properly marked 'override', however in the debugger you could see the
Message string which often have an informative value
 
G

Guest

If your connection string really is
"server=RAMESH\RAMESHSQL, 1433;Databse=Pubs;User ID=sa
then it's just a simple mis-spelling of Databas
"server=RAMESH\RAMESHSQL, 1433;Database=Pubs;User ID=sa

I use the following stock routine in one of my classes, which works on a Pocket PC to SQL Server 2000
SqlConnection db = new SqlConnection("server=" + serverName + ";database=" + databaseName + ";User ID=" + userID + ";Password=" + password + ";")

It is important to remember that the emulator effectively has a network card within it, and this is what enables the direct connection to SQL Server 2000. If you want an application to run on a real device, it requires either a wired network card or wireless LAN connection. You cannot access SQL Server 2000 through a cradle running ActiveSync as this only supports pass through HTTP and not the independent TCP/IP connections required for SQL Server 2000

Liam Westle

P.S. Never leave the admin login sa with a blank password, it's isn't considered good practice :)
 
R

Ramesh Singhvi

The error message is "SQL server does not exist or access denied". But
the sql server instance does exist coz I am able to connect it through
my desktop App.
Is there any limitation on Sql server instances which have "\" in
their name?? I have another instance of SQL server(7.0 ) which is
named as "Ramesh" and it is able to connect to it successfully. Please
guide me if I am missing something.
 
R

Ramesh Singhvi

Pardon me for the typo... I am still not able to connect it though. It
keeps giving error "SQL server does not exist or access denied"
although it does exist. Were you able to connect to a SQL Instance
having "\" in the name??
And yes I do not have my sa password blank. I did not put it in my
message.. Thanks for your suggestion anyways :)

Liam Westley said:
If your connection string really is,
"server=RAMESH\RAMESHSQL, 1433;Databse=Pubs;User ID=sa"
then it's just a simple mis-spelling of Database
"server=RAMESH\RAMESHSQL, 1433;Database=Pubs;User ID=sa"

I use the following stock routine in one of my classes, which works on a Pocket PC to SQL Server 2000,
SqlConnection db = new SqlConnection("server=" + serverName + ";database=" + databaseName + ";User ID=" + userID + ";Password=" + password + ";");

It is important to remember that the emulator effectively has a
network card within it, and this is what enables the direct connection
to SQL Server 2000. If you want an application to run on a real
device, it requires either a wired network card or wireless LAN
connection. You cannot access SQL Server 2000 through a cradle
running ActiveSync as this only supports pass through HTTP and not the
independent TCP/IP connections required for SQL Server 2000.
 
L

Lloyd Dupont

mmhh....
just for fun, try this:
"server=RAMESH\\RAMESHSQL, 1433;Database=Pubs;User ID=sa"

I put 2 '\', because \r is a special character
 
R

Ramesh Singhvi

Hi all,
I was finally able to connect to the SQL server using
"server=\\RAMESH\RAMESHSQL, 1433..." in the connection string..
 
R

Ramesh Singhvi

Hi all,
There is one intersting problem. My machine has 2 sql server instances
:
1. Ramesh -- SQL server 7.0
2. Ramesh\RameshSQL -- SQL server 2000

Even though I have connection string like "server=\\RAMESH\RAMESHSQL,
1433;Database=Pubs;User Id=sa;Password=xxx;", it always connects to
SQL server 7.0 instance and I only figured it out when I changed
Database to something else...
Please help me. It is really driving me crazy...
 
G

Guest

Ramesh

When you use SQL Server 2000 with multiple instances only the first instance communicates over port 1433 (standard Microsoft ADO port), other instances normally communicate over different port numbers. I suspect that SQL Server 7.0 is using port 1433, and SQL Server 2000 is on a different port.

To discover the port being used, right click on the server in SQL Server Enterprise Manager, select the General tab, click on the Network Configuration button at the bottom, click on TCP/IP in Enabled Protocols to highlight it, and then click on the Properties button. It is here that you set the Default port number

Regard

Liam Westley
 
G

Guest

Liam
To avoid the confusion, I uninstalled SQL server 7.0 from my machine. Also I verified the port # and it is 1433 for SQL 2000 instance, but still I am not able to connect. It keeps giving me error "Sql server does not exist or access dnied". Am I missing something

----- Liam Westley wrote: ----

Ramesh

When you use SQL Server 2000 with multiple instances only the first instance communicates over port 1433 (standard Microsoft ADO port), other instances normally communicate over different port numbers. I suspect that SQL Server 7.0 is using port 1433, and SQL Server 2000 is on a different port.

To discover the port being used, right click on the server in SQL Server Enterprise Manager, select the General tab, click on the Network Configuration button at the bottom, click on TCP/IP in Enabled Protocols to highlight it, and then click on the Properties button. It is here that you set the Default port number

Regard

Liam Westley
 
G

Guest

Ramesh

Ouch. Now it's getting tricky. I have to admit, I've never tried to connect to an instance of SQL Server from .NET CF, but I cannot believe that is the issue. So we have to go basic and start on some really obvious steps, which you may have already done, but it's always worth checking one last time

Firstly check that in SQL Server enterprise manager that in the SQL Server Properties dialog, Security tab, Authentication is switched to 'SQL Server and Windows' and not just 'Windows only'

Next test the SQL server connection from the desktop PC without getting involved in programming stuff (nothing to do with .NET but quickly tests credential settings). Create a text file on your desktop (Right click, New, Text Document) and rename it to TEST.UDL, double click it to open it. You now have an ADO connection dialog, click on Provider tab and select 'Microsoft OLE DB Provider for SQL Server'. Select Connection tab, highlight the server name, use the 'specific user name and password' and tick 'Allow saving password' (ignore security warnings), and select the database. Click on Test Connection to check you set everything up ok

If it worked click on OK to save the changes. Now right click on TEST.UDL on your desktop and select Open With, Notepad. In here you will find the ADO parameters (from which ADO.NET parameters are inherited) and you should have the correct server name listed as 'Data Source', the correct db as 'Initial Catalog'. I normally steal these values for the SQLCEClient connection string, with the ADO.NET naming convention

Hopefully, by proving that on the desktop you can get to the SQL Server instance, it will work on the PPC using ADO.NET

Regard

Liam Westley
 

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