PDA

Click to See Complete Forum and Search --> : mobile application cannot see remote sql server


mcbulan
Jun 20th, 2010, 07:16 AM
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 connects 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...

mcbulan
Jun 21st, 2010, 01:12 AM
here is the error code i received on conn.open()

---------------------------------------------------------

at System.Data.SqlClient.SqlConnection.OnError()

at System.Data.SqlClient.SqlInternalConnection.OnError()

at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()

at System.Data.SqlClient.TdsParser.Connect()

at System.Data.SqlClient.SqlInternalConnection.OpenAndLogin()

at System.Data.SqlClient.SqlInternalConnection..ctor()

at System.Data.SqlClient.SqlConnection.Open()

at MobilgSTS1.Form1.Form1_Load()

at System.Windows.Forms.Form.OnLoad()

at System.Windows.Forms.Form._SetVisibleNotify()

at System.Windows.Forms.Control.set_Visible()

at System.Windows.Forms.Application.Run()

at MobilgSTS1.Form1.Main()

---------------------------------------------------------

petevick
Jun 21st, 2010, 02:11 AM
Hi,
search the forum - there was a big discussion on this, and how to connect to SQL Express.

Should be something like:-
Dim Ccon As New SqlConnection("Persist Security Info=False;Integrated Security=False;Server=10.0.0.4;initial catalog=MYDBX_Data;user id=TEACHERA;password=mypassword;")

Pete

mcbulan
Jun 21st, 2010, 02:57 AM
it failed with this connectionstring! :confused::confused:

You are right! I'd betta if i search forum.

Thanks a lot

petevick
Jun 21st, 2010, 12:10 PM
Can you ping your server from your device?

techgnome
Jun 21st, 2010, 12:14 PM
Does your mobile device support wireless? I don't mean 3G wireless... I mean, does it have WiFi? If it does... then it needs to be connected to the network in order to run. Otherwise...it just isn't going to work.

That's why, as the error tells you: "Specified SQL server not found : MUSTAFA\MUSTAFASQL2" because, to your device, it doesn't exist.

-tg

mcbulan
Jun 22nd, 2010, 01:03 AM
Yes,
Device has wi-fi capability and i can ping the server (10.0.0.4) but cannot see database.
At the other hand, all other client PCs can reach server and database except mobile device.
:(:(:(

petevick
Jun 22nd, 2010, 05:30 AM
Is it SqlServer or Sql Express?

Is there an 'instance'?

The line below is taken from a working config file, connecting to SQL Express on port 1334

Persist Security Info=False;Integrated Security=False;Server=Till1\SqlExpress,1334;initial catalog=Waiter_BlackBull;user id=sa;password=elcastillo;

HTH

mcbulan
Jun 24th, 2010, 12:56 AM
Yes, there is an instance, it's sql express and i tried your last connectionstring as well. But it still fails!!!

But i found an information but dont know exactly what it means :

- You have to install MS Loopback Adapter and you must give an IP to the emulator as well.

Do you know how to configure/setup Loopback adapter??

Thank you

techgnome
Jun 24th, 2010, 06:38 AM
Wait.... is the problem ocurring when you run the app in the emulator? Or on the actual device itself?

-tg

petevick
Jun 24th, 2010, 06:53 AM
Wait.... is the problem ocurring when you run the app in the emulator? Or on the actual device itself?

-tg

Same question from me

Even in the emulator - you don't need a loopback

Here is a thread on the whole subject - http://www.vbforums.com/showthread.php?t=472561&highlight=SQLExpress

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