Select TOP, LIMIT workaround on SQLCE 2.0 or limiting the number of rows/getting a range from a dataset
Tech-Today

Select TOP, LIMIT workaround on SQLCE 2.0 or limiting the number of rows/getting a range from a dataset


Problem:
-In SQLCE 2.0 it is documented that 2 of the common used keywords are not supported in gettings a range of records from a dataset. They are LIMIT and TOP which are use this way:

LIMIT:
SELECT * FROM tableA LIMIT 5, 10;

This query will select a recordset from tableA, which will get 10 records starting from the fifth record. So it will return recordset 5 - 15.

TOP:
SELECT TOP 5 * FROM tableA;

The query will return the first 5 records.

Since these keywords are not supported by SQLCE 2.0, I've tried several possible workaround and one that worked for me is using the:

SqlCeDataAdapter.Fill(DataSet ds, int StartRecord, int MaxRecord, String "TableName") method, the parameters are self-explanatory. Using this method you will be able to select a range in your dataset. Example call:

public DataSet QueryAsDataset(string sql, int startRecord, int maxRecord) 
{
DataSet ds = new DataSet();
try
{
conn.Open();
SqlCeDataAdapter da = new SqlCeDataAdapter(sql, conn);
da.Fill(ds, startRecord, maxRecord, "czetsuya");
}
catch(SqlCeException e)
{
LogHelper.WriteLog(ErrorCode.DATABASE_EXECUTE_SQL_DATASET, e.Message);
}
finally
{
conn.Close();
}
return ds;
}




- Rss Feed Reader Implementation In C#
Included in this page: 1.) Rss feed model (which you can customized according to your needs) 2.) Rss feed reader My Objective is to read an rss feed of a news site like google and yahoo: For example we want to read the RSS feed of yahoo news in the Philippines:...

- How To Connect Msaccess Database From Java Using Jdbc Driver
The method is almost similar to my previous code, and like that it's better to explain it by code: private static Connection getConnection() { String driver = "sun.jdbc.odbc.JdbcOdbcDriver"; String url = "jdbc:odbc:anime"; //anime is the database...

- How To Connect Mysql Or Postgresql Server From Java Using Jdbc Driver
How to connect MySql or PostgreSql Server from Java using JDBC Driver I think the best answer to this is through coding: private static Connection getConnection() { Connection conn = null; try { Class.forName("com.mysql.jdbc.Driver"); //conn = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/anime",...

- Datagridtablestyle And Datagrid - Hide Datagrid Column
I was developing another windows mobile which has the requirement of using a datagrid for dataview. A DataGrid is a good control in presenting your data [http://msdn.microsoft.com/en-us/library/system.windows.forms.datagrid.aspx]. It has many customizable...

- Sqlce Get Last Insert Id, Convert Sqldecimal To Int32
Platform: Windows Mobile, SqlCE2.0 Problem: You want to get the id of the last query you insert. Solution: Using the @@identity you have to execute your queries like this: SqlCeConnection conn = null; try { conn = new SqlCeConnection(GetConnection());...



Tech-Today








.