Log JavaScript Errors – Part 1

Introduction

Recently in one of my projects, I’m informed by my QA team
that, in some pages they?re experiencing crashes, or some pages not functioning
properly after sometime.

Our team looked for options where there can be a code
generating errors. And the feedback I got, from the QA team was not helpful to
reproduce the error. But there is no doubt to look for areas only in JavaScript
coding, and not other than JavaScript coding.

Normally while releasing a project, what I would do is, just
escape/bypass the JavaScript errors. That means, whenever there is a JavaScript
error, it will not be reported to the user and they are suppressed.

Background

Following is the function, we can normally use to suppress the JavaScript errors.

var isDebugging = true;
function ErrorSetting(msg, file_loc, line_no) {
    var e_msg=msg;
    var e_file=file_loc;
    var e_line=line_no;
    var error_d = "Error in file: " + file_loc +
                          "\nline number:" + line_no +
                           "\nMessage:" + msg;
    if(isDebugging)
        alert("Error Found !!!\n--------------\n"+error_d);

     return true;
}
window.onerror = ErrorSetting;

window.onerror = ErrorSetting; this line will call the ‘ErrorSetting’
function, whenever there is a JavaScript error. And the function will return
true. So the user will not get JavaScript
error notifications and won’t be
annoyed. Continue reading “Log JavaScript Errors – Part 1”

SQLite GUI

SQLite GUI is a simple user Interface for SQLite dB. You can create / open a dB and also can create, delete and update tables in the database. All the tables in a database are shown in the DataGridView .
Data Types including BLOB are supported.

Dependencies
Add the reference SQLite.Net.dll to the project and use the namespace Finisar.SQLite to work with SQLite.

Finisar.SQLite

Finisar.SQLite is an ADO.NET Data Provider for accessing SQLite-Databases using the .NET-Framework. In SQLite a complete database is stored in a single disk file. SQLite is zero-configuration – no setup or administration needed. SQLite itself is “a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine” (quoted from the sqlite.org Website). The Finisar.SQLite Data Provider is an easy way to use the SQLite-Database in .net Languages like C# and VB.net.

Screenshot
sqliteGui Screenshot

Sample Code

try
{
//Connection string
string connString = String.Format(“Data Source={0};New=False;Version=3”, DB_NAME);

//Connecting database
SQLiteConnection sqlconn = new SQLiteConnection(connString);

//Open the connection
sqlconn.Open();

//Query
string CommandText = “Select name from sqlite_master;”;

//SQLiteDataAdapter to fill the DataSet
SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(CommandText, sqlconn);
dataAdapter.Fill(ds);

//Get the collection of rows from the DataSet
DataRowCollection dataRowCol = ds.Tables[0].Rows;

//Add the tables available in the DB to the combo box
foreach (DataRow dr in dataRowCol)
{
tablecombobox.Items.Add(dr[“name”]);
}

//Close the Connection
sqlconn.Close();

}
catch (SQLiteException sqlex)
{
MessageBox.Show(sqlex.Message);
}

To Do/Known Issues

Update cannnot be performed on table without primary key.
The SelectCommand must also return at least one primary key or unique column. If none are present, an InvalidOperation exception is generated, and the commands are not generated.
The alternative way is create select, insert and update command for that particular table. Refer MSDN .It will be available in the next version of SQLite GUI.

Download Code

Published in CodeProject.com on March 10, 2007