RegEx for data generation in VSTS DBPro

One way to generate data in DB Dude is to use the Regular Expression generator, but using regular expressions can be intimidating…

There is a great post by gert with list of RegEx expressions.

You can find it here.

I'm using Google Apps for Domains

It took me long enough, but finally I’m using Google Apps For Domains.

I’ve started using their free service (2 GB Email. with your own domain name) and have moved all of my current emailing aliases into that email service.

As you probably know, the spam filtering is awesome and the search capabilities are, well, Googlishious. No more need to pay for hosting or spam filtering!

I like the email web interface but do not forget: I can access my emails with pop3 from outlook, so no problem getting a “hard copy” of my emails offline.

My Calendar also hosted at google, so I’m all set.

Technorati Tags:

del.icio.us Tags:

Technorati Profile

Technorati Profile

New and better document management in Google Docs

Google docs looks amazing!

 

Navigation

The new home page has a sidebar that lets you filter the documents by tag (renamed to folder in the interface), by type or by collaborator. You can now see all your files by default, not only the documents or spreadsheets active in the last 30 days.
The folders can now have descriptions and you can send a document to a folder by using drag and drop!

Sorting

Google removed the option to sort the files by name or author, so the only available sort option is by date.

Search

The search box includes an autocomplete feature for file names, folders, authors.

WCF performance – Is it really better?

MSDN introduce a Performance Comparison of Windows Communication Foundation (WCF) with Existing Distributed Communication Technologies.

The conclusion is that “WCF is 25%-50% faster than ASP.NET Web Services, and approximately 25% faster than .NET Remoting. Comparison with .NET Enterprise Service is load dependant, as in one case WCF is nearly 100% faster but in another scenario it is nearly 25% slower. For WSE 2.0/3.0 implementations, migrating them to WCF will obviously provide the most significant performance gains of almost 4x.”

You can fine the entire comparison here.

ASP.NET AJAX Toolkit: new version available for download

I’ve just noticed there’s a new release of the Ajax Toolkit control with several improvements. Scott Guthrie has a cool post on the new stuff in the toolkit.

You can get it from here.

Save datagrid changes in the database

Once you want edit a recore, add new or deleted a recored in your data grid you may want to save it in the database.

How do we do it?

  1. Create UpdateCommand handler for the data grid
  2. Identify what DataGrid row was updated by getting the ItemIndex property of the row (Item object) passed in the event object. Then use the index value to get the corresponding value out of the grid’s DataKeys collection:
    • string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
  3. Get the changed values out of the DataGrid row. How?
    • From the item passed in the event object, get the appropriate cell (zero-based) out of the Cells collection from the item passed in the event object. For example, the left-most column in the grid is Cells(0).
    • For each cell, get its Controls collection, which contains all the elements that appear in the cell.
    • Get the first (and only) control out of the collection — for this example, a TextBox control. To get the TextBox, declare a local variable of type TextBox and cast the object in the Controls collection to it.
    • Get the TextBox control’s value (its Text property).
  4. Find the corresponding row in the data table. The dataset contains a special FindBy method — that locates a row by its primary key and returns a reference to it.
  5. Update the row by changing values in the row you located in Step 4.
  6. Send changes from the dataset to the database by calling the data adapter’s Update method.
  7. Switch the current row in the grid out of editing mode.
  8. Data-bind the DataGrid control.

Code example:

private void myDataGrid_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string productName, productDescription;
// Gets the value of the key field of the row being updated
string key = myDataGrid.DataKeys[e.Item.ItemIndex].ToString();
// Gets get the value of the controls (textboxes) that the user
// updated.
// Each cell has a collection of controls. In this case, a TextBox control.
// The first column — Cells(0) — contains the Update and Cancel buttons.
TextBox tb;
// Gets the value the TextBox control in the third column
tb = (TextBox)(e.Item.Cells[2].Controls[0]);
productName = tb.Text;
// Gets the value the TextBox control in the fourth column
tb = (TextBox)(e.Item.Cells[3].Controls[0]);
productDescription = tb.Text;
// Finds the row in the dataset table that matches the
// one the user updated in the grid. This example uses a
// special Find method defined for the typed dataset, which
// returns a reference to the row.
dsProducts.CategoriesRow r;
r = dsProducts.Categories.FindByProductID(int.Parse(key));
// Updates the dataset table.
r.ProductName = productName;
r.ProductDescription = productDescription;
// Calls a SQL statement to update the database from the dataset
sqlDataAdapter1.Update(dsProducts);
// Takes the DataGrid row out of editing mode
myDataGrid.EditItemIndex = -1;
// Refreshes the grid
myDataGrid.DataBind();
}

For more information about DataSet updates, navigate to: http://msdn2.microsoft.com/en-US/library/y2ad8t9c(VS.71).aspx

%d bloggers like this: