Exception connecting to SQL Server 2008 from Windows Mobile 6.0

I would like to connect to SQL Server from a Windows mobile application. I tried to do this, but it throws an SQL exception when the code tries to open the connection. I googled for this problem, and I found an article to make some configuration changes on SQL Server, and I followed it, and it throws the same exception

: http://netcf2.blogspot.com/2005/12/accessing-sql-server-express-from.html

Instruments:

  • SQL Server Management Studio 2008 R2
  • Windows Mobile 6.0
  • VS 2008
  • The C # project and SQL server were on the same computer, and I used the same code to connect to SQL Server from a desktop application, and it was successful.

Code:

SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=DBNAME;Trusted_Connection=yes;"); conn.Open(); 

Your answer will be highly appreciated.

+4
source share
4 answers

Most likely your connection string is the source of the error:

 Data Source=.;Initial Catalog=DBNAME;Trusted_Connection=yes; **** 

That . (period) means: you are trying to connect to a full-blown instance of SQL Server on this very device! . I highly doubt that you have installed SQL Server on your Windows Mobile device .....

Check out ConnectionStrings.com for a wealth of examples and explanations of the connection string. Basically, your connection string should most likely look something like this:

 Data Source=YourServerNameHere;Initial Catalog=DBNAME;Trusted_Connection=yes; 

Enter the name (or IP address) of your computer on which SQL Server really resides - it is definitely not on your mobile device ....

+2
source

I also have the same problem.

I used this connection string

Data Source = My-PC; Start Directory = TestDB; Persist Security Info = True; User ID = Admin; Password = ***** ";

then I tried it IP

"Data source = 10.219.47.79; Initial directory = TestDB; Persist Security Info = True; User ID = Admin; Password = ***** ";

Is that what you mean by IP? since I think we can run mobile applications on the same computer as the SQL server

0
source

Make sure your mobile device (emulator or physical device) can physically reach the remote PC that your SQL Server is running on.

If your SQL Server is running on a PC named "AppServer", for example, go to "Mobile Explorer"

Start screen

From the file explorer, go to the menu button at the bottom and select "Open Path"

File explorer

Enter the path to your SQL Server here

Network path

If you can get to it from there, you can get it from Visual Studio.

If you can’t get to it (as I suspect), Windows Mobile should provide you with a more informative error message, and you will find out that this is not a problem with your project, but a network connection problem.

[UPDATE] If you cannot connect to your current settings, you need to go to Settings on your device and configure the connection that your device uses to connect to your network.

Connections Screenshot

My emulator does not have a wireless card (as you can see in the image above), but you will need to configure a wireless card and a network router for the network to work together.

If you have not done so already, this question will be answered, and you will need to work to get your device connected to your network.

Here's a tutorial I found on the Internet: Texas A & M University Students: How to Connect to Campus Wireless Networks

0
source

Try using the PPP IP address on the computer instead of ".". Refer to this link to find out how to find the PPP IP address.

Link: Get the IP address of the host computer from Windows Mobile when connecting via ActiveSync

0
source

All Articles