This is the database.cs:
public bool Insert_ItemRecords(string itemID, string itemName, string itemDesc)
{
SqlCommand cmd_ItemList = new SqlCommand(); cmd_ItemList.CommandText "[VRM].[INSERT_ItemRecords]"; cmd_ItemList.CommandType = CommandType.StoredProcedure; cmd_ItemList.Parameters.Clear();
SqlParameter sqlParaItemID = new SqlParameter("@itemID", SqlDbType.VarChar, 10);
sqlParaItemID.Value = itemID;
cmd_ItemList.Parameters.Add(sqlParaItemID);
SqlParameter sqlParaItemName = new SqlParameter("@itemName", SqlDbType.VarChar, 100);
sqlParaItemName.Value = itemName;
cmd_ItemList.Parameters.Add(sqlParaItemName);
SqlParameter sqlParaItemDesc = new SqlParameter("@itemDesc", SqlDbType.VarChar, 1000);
sqlParaItemDesc.Value = fileName;
cmd_ItemList.Parameters.Add(sqlParaItemDesc);
return executeNotQuery(cmd_ItemList); }
This is the business logic i have defined at the apsx.cs:
protected void gvItems_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddNew"))
{
TextBox txtID = (TextBox)gvItems.FooterRow.FindControl("txtID");
TextBox txtItemName = (TextBox)gvItems.FooterRow.FindControl("txtItemName");
TextBox txtItemDesc= (TextBox)gvItems.FooterRow.FindControl("txtItemDesc");
osdb.Insert_ItemsRecords(txtID.Text, txtItemName.Text, txtItemDesc.Text);
BindGrid();
}
}
The error indicates:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
This sentence is highlighted in red:
osdb.Insert_ItemsRecords(txtID.Text, txtItemName.Text, txtItemDesc.Text);
BindGrid(true);
How do I set osdb to a valid instance?
Thanks!

New Topic/Question
Reply




MultiQuote







|