-
[RESOLVED] want to connect to sql server using mobile application
i am newbie to world of mobile application.
i have vs2005. i want to develop vs2005 mobile application for windows phone which connect to sql server which i have on server and connect to it and display some data depending on query.
can any one let me know how to start.i want to this using code. not any data-source. can anyone help me out what to do???
i think just first need to know how to connect to sql server in mobile device application.
i know this is silly question but not for me.
waiting for your reply .
-
Re: want to connect to sql server using mobile application
Hey,
Are you wanting to be able to have a database on the device, i.e. for when the application is being used off-line, or are you wanting to be to connect to a full blown SQL Instance when the mobile device is docked to a PC.
The two situations are very different.
One thing you could do is this:
Use SQL Server Compact Edition:
http://www.microsoft.com/Sqlserver/2...s/compact.aspx
On the device, that will give you a full relational database on the device. You can then use Merge Replication on the device to synchronize changes back to a full blown SQL Server Instance.
Gary
-
Re: want to connect to sql server using mobile application
HI SIR,
firstly thank you so much for your quick reply.
regarding your reply.
no i dont want to have database on my mobile device, my application is just like client sending request to sql server which is at remote place and get result from sql server depending on sql query.
here is what exactly i want to do, i want to connect to sql server which is remote at remote place. its same like windows application which connect remote sql server so that i can execute query on it and have result.
again no database on mobile device.
waiting for your reply.
-
Re: want to connect to sql server using mobile application
Hi,
use the SqlClient namespace and just connect to your server, and issue commands as you would with a windows forms application.
If you search this forum, there are examples of connection strings etc.
Pete
-
Re: want to connect to sql server using mobile application
Which connection are you using from the Mobile Device?
Wifi, GPRS?!?
You are going to need to connect as Pete has suggested. Have a look at:
http://www.connectionstrings.com/
For getting the correct connection string.
Gary
-
Re: want to connect to sql server using mobile application
i have correct connetion string.
but where i try imports system.data.sqlclient and declare sqlconnetion variable.
i get this error
Code:
Error 1 Reference required to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac, Retargetable=Yes' containing the implemented interface 'System.Data.IDbConnection'.
.
i already have reference to this file in project but version is 3.5. i dont see version 2.0 in my reference.
-
Re: want to connect to sql server using mobile application
I don't think the full SQLClient is available in the Compact Framework... but I'm not 100% sure about that.
-tg
-
Re: want to connect to sql server using mobile application
There is an article here about configuring VS2005 to work with later versions of SQL CE - it may help you
-
Re: want to connect to sql server using mobile application
Quote:
Originally Posted by
techgnome
I don't think the full SQLClient is available in the Compact Framework... but I'm not 100% sure about that.
-tg
Yes - SQLClient is available for mobile development - we have a few things missing, but SQL access is not one of them :)
-
Re: want to connect to sql server using mobile application
so any there is no way to connect to my remote sql server from mobile???
-
Re: want to connect to sql server using mobile application
Quote:
Originally Posted by
bhavin12300
so any there is no way to connect to my remote sql server from mobile???
Yes - SQLClient works - I have used it in several applications.
With the right references and connection string, it is no different than accessing SQLServer from a windows forms application.
-
Re: want to connect to sql server using mobile application
Hey,
I sense an example is needed....
A quick google turned up this:
http://www.devbuzz.com/Articles/zinc...erver_pg1.aspx
Is that by you Pete?
Gary
-
Re: want to connect to sql server using mobile application
Quote:
Originally Posted by
petevick
Yes - SQLClient works - I have used it in several applications.
With the right references and connection string, it is no different than accessing SQLServer from a windows forms application.
but sir i get following error when i add reference to system.data.sqlclient.
Reference required to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac, Retargetable=Yes' containing the implemented interface 'System.Data.IDbConnection'.
am i doing anything wrong???
-
Re: want to connect to sql server using mobile application
Hey,
Can you explain the exact steps you have taken to arrive at this error?
Have you added a reference to the System.Data assembly?
Try following the steps in the article that I linked to.
Gary
-
Re: want to connect to sql server using mobile application
Are you adding a 'desktop' version of the system.data??
Yes Gary - the article is by me :)
Pete
-
Re: want to connect to sql server using mobile application
Quote:
Originally Posted by
petevick
Yes Gary - the article is by me :)
Ha ha, that's quite funny!! What are the chances that the first article I would find on this topic would be written by you :)
Gary
-
Re: want to connect to sql server using mobile application
Quote:
Originally Posted by
petevick
Are you adding a 'desktop' version of the system.data??
Yes Gary - the article is by me :)
Pete
first my system.data.sqlclient is C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Devices\Client\System.Data.SqlClient.dll
and system.data is
C:\Program Files\Microsoft.NET\SDK\CompactFramework\v2.0\WindowsCE\System.Data.dll
hi thanks for that article.
but i am getting following error while try to connect to my local sql server.
SAI\SQLEXPRESS server not found.
my connection string is this. it perfectly worked in windows application.
server=SAI\SQLEXPRESS;Integrated Security=true;Database=shopbot
-
Re: want to connect to sql server using mobile application
Hey,
It is unlikely that your device is going to be able to resolve the name of your server, i.e. SAI. You are going to need to give it an IP Address to connect to, and also, unless the device is connected to the domain, you are going to need to give it a user name and password in the connection string to connect to the database with.
Gary
-
Re: want to connect to sql server using mobile application
Quote:
Originally Posted by
gep13
Hey,
It is unlikely that your device is going to be able to resolve the name of your server, i.e. SAI. You are going to need to give it an IP Address to connect to, and also, unless the device is connected to the domain, you are going to need to give it a user name and password in the connection string to connect to the database with.
Gary
i changed ip address to this placing ip adreess.
"server=127.0.0.1;Integrated Security=True;Database=shopbot;"
now getting error like this.
server does not exist or access denied.
-
Re: want to connect to sql server using mobile application
127.0.0.1 -- isn't that the loopback address? In other words, that's the same as doing "local" for the server... which means it's looking at the device, not the server.
-tg
-
Re: want to connect to sql server using mobile application
Hey,
Yip, 127.0.0.1 is the equivalent of localhost, i.e. itself.
You have said already that you are trying to connect to a remote server, so this IP address is certainly not it.
Do you know the IP address of the server? If not, you should be able to get it by opening up a command prompt and typing:
Also, it doesn't look like you have modified the connection string to include an authorized user name and password. You are going to need to do this before the connection will work.
Have you read the article? This topic is discussed in detail at the bottom half of the first page.
Gary
-
Re: want to connect to sql server using mobile application
i think problem is in my emulator is not connected to internet.
coz when i use following code just to get webpage it gives me error that "Could not establish connection to network."
Code:
Dim web1 As System.Net.HttpWebRequest
Dim html As String
web1 = System.Net.WebRequest.Create("http://www.google.com")
Dim response5 As HttpWebResponse = web1.GetResponse
Dim reader2 As StreamReader = New StreamReader(response5.GetResponseStream, System.Text.Encoding.GetEncoding(1252))
Try
html = reader2.ReadToEnd
response5.Close()
reader2.Close()
Catch ex As Exception
End Try
-
Re: want to connect to sql server using mobile application
Hi,
there are many discussions (and solutions) on the forum about connecting to SQL Express - bottom line is you need the IP address.
I would also test against a server on your network before being brave enought to test it on the internet. You will need to cradle your device emulator.
In Visual Studio, when the emulator is running, click on Tools>Device Emulator Manager.
Scroll down the list, looking for your emulator (which should show as connected), right-click on it, and choose cradle. This should connect the device using activesync (or WMDC), and you should be able to access the internet. If you have problems connecting, make sure activesync allow connections to DMA
-
Re: want to connect to sql server using mobile application
Hey,
Here is some guidance on cradling the emulator:
http://windowsmobilepro.blogspot.com...3-quickly.html
Gary
-
Re: want to connect to sql server using mobile application
hi,
its working now.
i installed active sync 4.5 and virtual pc and now its succesfully connecting to internet .
thank you so much expert . thanks for your really quicky reply.
-
Re: want to connect to sql server using mobile application
Hey,
Good stuff, glad to hear that you have got it working.
Remember to follow the links in my signature to mark your thread as resolved.
Gary