How do i connect to a database from c# with compact framework. (PDA)

the database runs on the desktop.

i use Pervasive on the destop. i want write directly on the desktop. is that possible, and how?

Comments
duplicate posts

i want connect to a database on a server from a pda.

i tryed to make a database connetion from Visual Studio, but in the list i don't see Pervasive SQL. and if i can connect to a database from visual studio, if i release the project, work it than on the pda?

Why on earth would you use PSQL? Isn't that still based on the old btrieve engine?

Anyway to answer your question -- As far as I know you have to create an ODBC connection and dig up a pervasive driver from somewhere and cross your fingers that it works. Do you have the drivers installed on your development machine and PDA? Have you created a user or system DSN in your ODBC Data Source manager? Start -- Programs -- Administrative Tools -- Data Sources

You can synchronise sql data with Using Remote Data Access (RDA)

Remote data access (RDA) in Microsoft SQL Server 2005 Compact Edition (SQL Server Compact Edition) lets an application access data from a remote SQL Server database table. It can also store, read, and update that data in SQL Server Compact Edition, and then update the original SQL Server table.

i have maked a sql ce database in visual studio 2008.
now i want read that data with c# compact framework.
but it does not work.
i have this code for the connection:

string connectionString = string.Format("test.sdf", "");
            
            SqlCeConnection cn = new SqlCeConnection(connectionString);
            
            if (cn.State == ConnectionState.Closed)
            {
                cn.Open();
            }


            string sql = "select Omschrijving from Orderregels";

           
                sql += "where Ordernummer = 3";
            
            
            try
            {
                SqlCeCommand cmd = new SqlCeCommand(sql, cn);
                cmd.CommandType = CommandType.Text;
                
             
                SqlCeResultSet rs = cmd.ExecuteResultSet(
                    ResultSetOptions.Scrollable);

                if (rs.HasRows)
                {

                    int ordOmschrijving = rs.GetOrdinal("Omschrijving");
                    

                    StringBuilder output = new StringBuilder();
                    

                    rs.ReadFirst();
                    output.AppendLine(rs.GetString(ordOmschrijving));
                    

                    while (rs.Read())
                    {
                        output.AppendLine(rs.GetString(ordOmschrijving));
                    }
                    

                    tb_artOmschr.Text = output.ToString();
                }
                else
                {
                    tb_artOmschr.Text = "No Rows Found.";
                }
            }

            catch (SqlCeException sqlexception)
            {
                MessageBox.Show(sqlexception.Message, "Oh Crap.");
            }
            
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Oh Crap.");
            }
            
            finally
            {
                cn.Close();
            }
        }

what is wrong? i have a error on this:
SqlCeConnection cn = new SqlCeConnection(connectionString);

how can i write or read data from pervasive sql on the server?

this is what i now have:

//  The local connection string.
        private string strConnLocal = "Data Source ="
                        + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\test.sdf;";

        //  The remote connection string.
        private string strConnRemote = "Provider=sqloledb; "
                                     + "Data Source=test; "
                                     + "Initial Catalog=OURPDA; "
                                     + "Integrated Security=SSPI;";

        //  The URL
        private string strURL = "http://169.254.229.103/OURPDA/sqlceca35.dll";

        public void doen()
        {
            //  Create a remote data access object
            SqlCeRemoteDataAccess rdaNW =
               new SqlCeRemoteDataAccess(strURL, strConnLocal);
            try
            {
                //  Have RDA:
                //     Create local tables named Categories and
                //        ErrorCategories.  
                //     Connect to the remote server and submit the
                //        SELECT statement.
                //     Place the results in the local Categories table.
                rdaNW.LocalConnectionString = strConnLocal;
                rdaNW.InternetUrl = strURL;
                rdaNW.InternetLogin = "";
                rdaNW.InternetPassword = "";
                rdaNW.Pull("Department",
                            "SELECT Name " +
                            "FROM Department " +
                            "WHERE Room_Number = 100",
                            strConnRemote,
                            RdaTrackOption.TrackingOnWithIndexes,
                            "ErrorCategories");
            }
            catch (SqlCeException exSQL)
            {
                HandleSQLException(exSQL);
            }
            finally
            {
                rdaNW.Dispose();
            }
        }
This article has been dead for over six months. Start a new discussion instead.