Connection to SQL Server from within the emulator - newbie questio

G

Guest

I am trying to connect to a SQL Server database running on my laptop from
within the emulator. I am receiving the 'SQL Sever does not exist or access
denied' error. (I can connect to the database sucessfully from within a
normal Visual Studio Windows application using the same connection string)

I have the emulator 'cradled' before I run the app. It appears to be
connected as I can browse the Internet from within the emulator.

Are there other emulator settings that need to be changed?

Any help would be appreciated as this has stopped me in my tracks.

Thanks,
Matthew
 
G

Ginny Caughey [MVP]

Matthew,

Are you connecting to SQL Server using its IP address? For example, any
localhost address won't work from a device or emulator. If you're using
Integrated Security you must provide the domain\user name and password from
mobile devices although you don't from desktops.
 
G

Guest

Hi Ginny,

Thanks for your reply. I am using a laptop that has a wireless broadband
connection but is not plugged into a physical network connection. I have
tried using IP address 127.0.0.1 but it doesn't work.

I am not really up to speed with IP addresses. How do I know which IP
address to use. Sorry if this is a really dumb question.

Regards,
Matthew
 
G

Ginny Caughey [MVP]

Matthew,

If there is no real network address, you can use the Microsoft Loopback
Adapter. Use the search engine of your choice to search for that to see how
to install it, then use ipconfig.exe to see what IP address the loopback
adapter has.
 
G

Guest

Hi Ginny,

Thanks for sticking with me on this one. I have installed the loopback
adapter, checked the IP address and can ping the IP address from the command
line.

I am now trying to connect but getting a different error now - "Invalid
Connection".

Is there anything I need to change in SQL Server now that I have the
loopback adapater installed? What is the best way to test the SQL connectiopn
using the IP address with another application apart from the emulator?

Thanks once again.
Matthew
 
G

Ginny Caughey [MVP]

Matthew,

I tend to more testing with a real device rather than an emulator, so that
might be an option for you. It doesn't have to be the exact device - just
close enough so hopefully you can get past this snag. What is the connection
string that works in the desktop app?
 
G

Guest

Hi Ginny,

Good idea. I'll try and get hold of a device ASAP so I can keep moving ahead.

Glad you asked about the Windows connection string. I just realised I have
only tested the Windows app using the following:

string strConn = "Data Source=(local);Initial Catalog=StockLogixDev;User
ID=sa;Password=kogarah";

I haven't tested it using an IP address. I'll give that a go.

Thanks again.

Matthew
 
G

Guest

Hi Ginny,

I finally got to the bottom of this. It turns out that my laptop had the
'Personal' edition of SQL Server 2000 installed. This edition doesn't seem to
listen for any tcp connections at all. I installed the 'Developer' edition of
SQL Server 2000 and all is good!

Thanks again for all your help.

Regards,
Matthew
 
G

Ginny Caughey [MVP]

Matthew,

Thanks for reporting back. SQL Server Express also ships by default with tcp
disabled for security reasons, but you can enable it using the SQL Server
Configuration Manager. So keep that in mind if you upgrade to SQL Server
2005. I'm glad you have things working now.
 
G

Guest

Hi Ginny,

Thanks, I'll keep that in mind.

How you developed many "permanently connected" type applications. I am
trying to find out the best way to handle the database connection. Don't know
whether to create a database connection and pass that between forms or to
have a connection on each form.

Any advice would be most welcome.

Thanks & Regards,
Matthew
 
G

Ginny Caughey [MVP]

Matthew,

For internal data (SQL Mobile) I tend to use a single connection for the
whole app. I also typically use a single connection in desktop apps for SQL
Server, but on mobile devices I don't have clients with the type of
infrastructure that permits a SQL Server connection all the time from their
mobile devices, so I don't have production experience with that. Perhaps
somebody else will provide some opinions.

In any case, you need to make sure you have some way of handling the
situation where your connection might not be valid, whether you use a single
one throughout the app or not. Also of course transactions are bound to
connections, so with a single connection you can't have but one active
transaction at a time.
 

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