mobile application cannot see remote sql server?
I am sorry for bothering you with my probably low level question.
I would like to develop a very very very simple application which will connect the MS SQL SERVER in my notebook and will be run at hand terminal-with windows mobile 6.
Here is the code which i used :
Dim strSQL As [String] = "SELECT COUNT(studentid) AS totalp from Students where gender='m' "
' Dim Conn As New SqlConnection("Data Source=10.0.0.4\MUSTAFASQL2;Initial Catalog=MYDBX;User ID=TEACHERA") <<< i used this too,
' Dim Conn As New SqlConnection("Data Source=10.0.0.4:1433\MUSTAFASQL2;Initial Catalog=MYDBX;User ID=TEACHERA;") <<< and also tried this
Dim conn As New SqlConnection("Data Source=MUSTAFA\MUSTAFASQL2;Initial Catalog=MYDBX;User ID=TEACHERA;")
Conn.Open() *<<<<<<<<< crashes here with thi开发者_运维技巧s error : "Specified SQL server not found : MUSTAFA\MUSTAFASQL2"*
Dim cmd As New SqlCommand(strSQL, Conn)
Dim musreader As SqlDataReader = cmd.ExecuteReader
While musreader.Read
total.Text = musreader.Item("totalp").ToString
End While
Conn.Close()
on button click.
Some details : Device : Windows Mobile 6.1 classic
Local : SqlExpress and i can reach from many computers, i mean there is no problem accessing remotely to my SQL Server.Please help me, all helps are appreciated. Thanks a lot. Please let me know if you need to know more details for help...
It seems problem not in your code but in connection to 10.0.0.4 server.
If the other computers are on the same network then they will be able to see your SQL Server instance. However, if the mobile device isn't (which I wouldn't have thought it would be) then it won't.
The IP address 10.0.0.4 (which I see you've tried to use in the commented out connect statements) is an internal address which won't be visible to the wider internet.
You need to put your database on an external facing server with a public IP address and connect to that.
精彩评论