Wednesday, December 14, 2011

Opening a PDF File.

    string path = Environment.CurrentDirectory + "\\" + UserMessageStrings.HelpFile;
     Process.Start(path);

Transactions

using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
            {
             //your insert/delete/update here.
                ts.Complete();
            }


Note:  If any operation fails then it will rollback automatically.

Binding to a DataSource Controls.

Binding to a Datasource Controls
-----------------------------------
Dictionary<int, string> source= PetDataAccess.GetStateByCountryId(stateId);
comboBox.DataSource = new BindingSource(breeds, null);                                        comboBox.DisplayMember = "value";
comboBox.ValueMember = "key";