locked
Remote SQL database connection - SqlException RRS feed

  • Question

  • Greetings I have following problem. Searched everywhere, tried every solution i could found but it's still unresolved.

    I try to connect to MSSQL database which is on remote server (hosting) using Windows Mobile (emulator).

    That's what I do.

    - Create new project
    - Add reference System.Data.SqlClient
    - Data -> Add New Source my connection string is Data Source=79.96.107.180;Initial Catalog=albert_mcarthurs1;User ID=albert_mcarthurs1;Password=xxx;
    - Wizard sucessfuly establishes the connection (connection test says everything's ok) and also gets data from my database.
    - I add DataGrid from Data Sources to my grid

    After deployment i get SqlException in debugger with following data:

    Errors; {System.Data.SqlClient.SqlErrorCollection} 
    Message: "SqlException" 
    Number: 14 
    Procedure: "ConnectionOpen (Invalid Instance())." 
    StackTrace:
    "at System.Data.SqlClient.SqlConnection.OnError()\r\nat System.Data.SqlClient.SqlInternalConnection.OnError()\r\nat System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()\r\nat System.Data.SqlClient.TdsParser.Connect()\r\nat System.Data.SqlClient.SqlInternalConnection.OpenAndLogin()\r\nat System.Data.SqlClient.SqlInternalConnection..ctor()\r\nat System.Data.SqlClient.SqlConnection.Open()\r\nat System.Data.Common.DbDataAdapter.QuietOpen()\r\nat System.Data.Common.DbDataAdapter.FillInternal()\r\nat System.Data.Common.DbDataAdapter.Fill()\r\nat System.Data.Common.DbDataAdapter.Fill()\r\nat DeviceApplication5.albert_mcarthursDataSetTableAdapters.usersTableAdapter.Fill()\r\nat DeviceApplication5.Form1.Form1_Load()\r\nat System.Windows.Forms.Form.OnLoad()\r\nat System.Windows.Forms.Form._SetVisibleNotify()\r\nat System.Windows.Forms.Control.set_Visible()\r\nat System.Windows.Forms.Application.Run()\r\nat DeviceApplication5.Program.Main()\r\n"

    Debugger marks this line of code
    int returnValue = this.Adapter.Fill(dataTable);

    I tried changing Data Source in my string for 79.96.107.180,1433 or 79.96.107.180,1433/SQL03 or 79.96.107.180/SQL03 or 79.96.107.180/SQL all the variants but in most cases wizard doesn't connect to a database and when i change it manualy in code it ends also with SqlException.

    Tried to connect without use of DataSets, I mean using code directly.

    SqlConnection myConnection = new SqlConnection(Data Source=79.96.107.180;Initial Catalog=albert_mcarthurs1;User ID=albert_mcarthurs1;Password=xxx;);

    etc.

    and result is the same.

    When i do same procedure for regular Windows application it connects without any problem, so the problem doesn't seem to be on server side.

    My emulator has it's network connection well configured (Internet Explorer browses websites)

    Can anyone help me with that couse I'am a bit desperate about that.

    Thx in advance.

    Thursday, July 29, 2010 11:22 PM

Answers

  • Is your server configured for TCP/IP connections on a fixed port (1433 by default)? If not device will not be able to connect (while desktop would work fine because it has other connection options like named pipes).

    See this on how to configure server and which connection string to use on device.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, July 30, 2010 12:42 AM