.net-3.5

Constructor code: When to leave empty and when to instantiate?

Below is the sample code of one of my class: #region Constructors public ItemMaster() { } public ItemMaster(string argItemName, string argItemCode, decimal? argStockInHand, decimal? argAlertLevelQty, string argUnit, decimal? argDiscount, string argWhetherInPercent, int argCategoryID) { this.ItemName = argItemName; this.ItemCod...

Passing query as parameter.

I know, it is not recommended. The possible risk of SQL Injection. In my present app., I created a class containing reusable functions. One such function is this: public static Int32 InsertNewRecord(string myQuery) { ModCon.OpenConnection(); MySqlCommand cmdInsert = new MySqlCommand(myQuery, ModCon.myCN); try { ...

Object Reference not set to an instance of an object

I have a form which has a search feature - a single text field and command button; when the text field is filled-in a database query is executed and the result (if one result returned) is shown on the form via dynamic control fields. When the search feature is used for the first time, the fields are created and the data is returned from...