Click here to Skip to main content
12,549,311 members (43,477 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked

Pocket PC Personal MP3 Disc Catalogue Search Tool

, 21 Sep 2005 CPOL
Rate this:
Please Sign up or sign in to vote.
Windows Mobile application to search MP3 music catalogue
Sample Image - PocketCatalogue.gif


This application is essentially a search tool for finding what Disc Number the Music Album I want to listen to is on. This application also contains functionality to download its data from the central Database server (via a WebService).

I'm still actively working on this project, so please give me your constructive comments and design suggestions. Right now, this app is very specialized for my needs, but if there is enough interest (and good design direction ideas) I could easily be persuaded to update and morph the project.

Framework note

Special note: Thanks to the following article on CodeProject. It helped me a lot (plus I sampled parts of their code).


I have an extensive collection of MP3s that I sort by Album folder and burn onto CD-R for use in my car stereo. Once I got to 100 discs (Over 900 albums) I realized that I needed a better way of finding the music I wanted to listen to. So I created a MySQL database on my server and a search tool on my Pocket PC.


Part of the code used to create the database that is used on the Pocket PC:

// This code is in the frmMain_Load event of the frmMain class
PocketCatalogue.Database myDB;
myDB = new Database(PathToDatabase,DatabaseName);

// This code is in the Database class
public void CreateDB() {
    if (!System.IO.File.Exists(_pathToDatabase + _databaseName)) {
        SqlCeEngine engine;
        engine = new SqlCeEngine("Data Source = " + _pathToDatabase + _databaseName);
        engine = null;
public void CreateTables(){
    if (conn == null) {GetConnected();conn.Open(); }
    try {
        string SQL = "CREATE TABLE Albums ( " +
            "DiscID int, " +
            "AlbumID int, " +
            "ArtistName nvarchar(254), " +
            "AlbumName nvarchar(254), " +
            "Genre nvarchar(45) )";

        SqlCeCommand createTable = conn.CreateCommand();
        createTable.CommandText = SQL;

        SQL = "CREATE TABLE Discs ( " +
            "DiscID int, " +
            "DiscNumber int, " +
            "DiscName nvarchar(45), " +
            "HasLabel int )";

        createTable = conn.CreateCommand();
        createTable.CommandText = SQL;

    } catch (System.Data.SqlServerCe.SqlCeException ex) {
        MessageBox.Show(ex.Message, "DB Error");
private void GetConnected(){
    conn = new SqlCeConnection("Data Source = " + _pathToDatabase + _databaseName);

Part of the code used to check for network connectivity before enabling the WebService calls:

// This code is in the ConnectivityTest class
public bool IsWebAccessible() {
    HttpWebRequest hwrRequest;
    HttpWebResponse hwrResponse;

    string strUrl = @"";
    bool bConnected = false;

        hwrRequest = (HttpWebRequest)WebRequest.Create(strUrl);
        hwrRequest.Timeout = 10;
        hwrResponse = (HttpWebResponse)hwrRequest.GetResponse();

        if(hwrResponse.StatusCode == HttpStatusCode.OK){
            bConnected = true;
    }catch(WebException we){
        bConnected = false;
    }catch(Exception ex){
        bConnected = false;
        hwrRequest = null;
        hwrResponse = null;

    return bConnected;

Method used to make the DataGrid pretty and autosized:

// This code is in the Util class
public static void FormatDataGrid(DataGrid dg, DataSet ds) {
    Font f2 = new Font("Tahoma",7, System.Drawing.FontStyle.Regular);
    dg.Font = f2;
    if (ds != null) {
        if (dg.TableStyles.Count > 0)
        float sumWidths = 0.0f;
        foreach (DataTable dt in ds.Tables) {
            DataGridTableStyle DGStyle = new DataGridTableStyle();
            DGStyle.MappingName = dt.TableName;
            DataGridTextBoxColumn textColumn;
            System.Collections.ArrayList cWidths;
            cWidths = new System.Collections.ArrayList();
            Graphics g = dg.CreateGraphics();
            Font f = dg.Font;
            SizeF sf;
            int y = 0;
            foreach (DataColumn dc in dt.Columns) {
                sf = g.MeasureString("W" + dc.Caption, f);
                if (y == 0)
            foreach (DataColumn dc in dt.Columns) {
                textColumn = new DataGridTextBoxColumn();
                textColumn.MappingName = dc.ColumnName;
                textColumn.HeaderText = "" + dc.Caption;
                textColumn.Width =
                sumWidths += textColumn.Width;

Example of one of the many asynchronous WebService calls:

// This code is in the tabMain_SelectedIndexChanged event of the frmMain class
PocketCatalogue.SyncService.MusicCatalogueSync wsSync =
		new PocketCatalogue.SyncService.MusicCatalogueSync();
AsyncCallback cbDisc = new AsyncCallback(ServiceCallback_DiscCount);
wsSync.BeginGetDiscCount(cbDisc, wsSync);

// This code is in the frmMain class
private void ServiceCallback_DiscCount(IAsyncResult ar) {
    try {
        PocketCatalogue.SyncService.MusicCatalogueSync wsSync =
        this.lblDiscsServer.Text = wsSync.EndGetDiscCount(ar).ToString();
        bDiscCountReturned = true;
        if ((bDiscCountReturned) && (bAlbumCountReturned) && (bTrackCountReturned)) {
            this.cmdSync.Enabled = true;
            this.lblStatusMessage.Text = "";
            tmrProgress.Enabled = false;
    } catch (Exception) {
        MessageBox.Show("Error terminating Web Service call", this.Text);
        tmrProgress.Enabled = false;

Points of Interest

This was my first Pocket PC Application and I really enjoyed it, and I plan on doing many more. I learned lots of things from this little project including threading on a mobile device, SqlCE database technologies and Asynchronous WebService access.


  • Version 1.0, September 21 2005

Coming Soon

  • Version 1.1 will include the create statements necessary for making the corresponding Server MySQL Database
  • Version 1.2 will include the code for the WebService being used


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
Canada Canada
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionPC version? Pin
Alan Holden28-Apr-14 2:50
memberAlan Holden28-Apr-14 2:50 
GeneralUnable to download the source code Pin
ravi42213-Apr-07 22:22
memberravi42213-Apr-07 22:22 
GeneralExtend or port project to support MP3 Tunes service Pin
daluu28-Feb-07 15:55
memberdaluu28-Feb-07 15:55 
Generalrecompiling to wm5 device Pin
boxman128-May-06 10:06
memberboxman128-May-06 10:06 
GeneralRe: recompiling to wm5 device Pin
boxman110-Jun-06 9:22
memberboxman110-Jun-06 9:22 
GeneralInstall help Pin
matteof8-Jan-06 0:24
membermatteof8-Jan-06 0:24 
QuestionWhere I can find webservices ? Pin
noce2k4-Jan-06 5:28
membernoce2k4-Jan-06 5:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161021.1 | Last Updated 21 Sep 2005
Article Copyright 2005 by micahbowerbank
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid