locked
Connecting to Sql server 2005 RRS feed

  • Question

  • Hai

    i am new to Mobile development

    i just want to create a simple database application, first i tried to create a insert in to table(it's a sample try)

     button click Code

                    SqlCeConnection con = new SqlCeConnection("server=.;database=master;User Id =sa;pwd=pass");

                    SqlCeCommand cmd = new SqlCeCommand("insert into test values('" + textBox1.Text + "','" + textBox2.Text + "'", con);

                    con.Open();

                    cmd.ExecuteNonQuery();

                    con.Close();

     

    it's showing error in sqlconnection "server"

    i tried this in a window mobile 6 professional emulator

    and i created the project selecting "6 prof sdk" and ".net cf 3.5"

    database sql server 2005(desktop) 

    and what i have to do to put this in a mobile and access database through internet or wifi network

    Monday, November 22, 2010 10:24 AM

Answers

  • Hi,

    Please follow this article. You can download the attached sample also.

    http://www.malleswar.com/viewarticle.aspx?articleid=17

    Regards,

    Malleswar

    Monday, November 22, 2010 10:49 AM
  • Hi Alex,

    you can try two different approach for your problem:

    1.use a local SQLCE database on the device and mange all the operation locally.

    2.Connect to a remote SQL DB using RDA, with this method you can retrieve the necessary infos from the host DB and save (and use) locally to a SQLCE DB that you can use when the device is disconnected also.

    The RDA would be configured with different types of connection (dock, WiFi, GPRS, CDMA etc).

    For reference about the RAD refer to http://msdn.microsoft.com/en-us/library/ms172917(SQL.100).aspx

     

    Regards

    Marco


    MCTS Windows Mobile 6.5
    • Marked as answer by Bin-ze Zhao Friday, November 26, 2010 3:04 AM
    Tuesday, November 23, 2010 10:57 PM

All replies

  • Hi,

    Please follow this article. You can download the attached sample also.

    http://www.malleswar.com/viewarticle.aspx?articleid=17

    Regards,

    Malleswar

    Monday, November 22, 2010 10:49 AM
  • Thank you for reply

    i tried through but still it is throwing sqlexception

    "    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, TdsParserState state)

       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, TdsParserState state)

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

       at System.Data.SqlClient.TdsParser.Connect(String host, SqlInternalConnection connHandler, Int32 timeout)

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

       at System.Data.SqlClient.SqlInternalConnection..ctor(SqlConnection connection, Hashtable connectionOptions)

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

       at DirecttoDatabase.Form1.fillGrid()

       at DirecttoDatabase.Form1.Form1_Load(Object sender, EventArgs e)

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

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

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

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

       at DirecttoDatabase.Program.Main()

    "

    i tried modifying your sample code - connection string to my ip and database to mine also with table

    Please Help

    Tuesday, November 23, 2010 7:19 AM
  • Hi,

    Have you changed the server side TCP/IP properties as I mentioned in article?  It worked perfectly.

    Please let me know the error message with my application.

    Regards,

    Malleswar

    Tuesday, November 23, 2010 9:08 AM
  • Hi Alex,

    you can try two different approach for your problem:

    1.use a local SQLCE database on the device and mange all the operation locally.

    2.Connect to a remote SQL DB using RDA, with this method you can retrieve the necessary infos from the host DB and save (and use) locally to a SQLCE DB that you can use when the device is disconnected also.

    The RDA would be configured with different types of connection (dock, WiFi, GPRS, CDMA etc).

    For reference about the RAD refer to http://msdn.microsoft.com/en-us/library/ms172917(SQL.100).aspx

     

    Regards

    Marco


    MCTS Windows Mobile 6.5
    • Marked as answer by Bin-ze Zhao Friday, November 26, 2010 3:04 AM
    Tuesday, November 23, 2010 10:57 PM