views:

42

answers:

2

Hello all,

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 this 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...

A: 

It seems problem not in your code but in connection to 10.0.0.4 server.

STO
Thanks for reply STO, but i can reach SQL Server with this connection string from different computers. But it doesnt work in Mobile application (from mobile device(emulator as well))
Mustafa KAMAN
A: 

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.

ChrisF
But this application will work in a LAN (several computers and a mobile hand terminal (Mobile Classic 6.1). That's why i am trying to develop for internal network (LAN)
Mustafa KAMAN
If the mobile device is on the same network, then ignore this.
ChrisF