" The Connection Property has not been initialized in asp.net." for below code...
private void InsertCommand()
{
try
{
//string str = "";
String pfname = FileUpload1.FileName.ToString();
String fname = System.IO.Path.GetFileNameWithoutExtension(pfname).ToString();
String ext = System.IO.Path.GetExtension(pfname);
fname = fname + DateTime.Now.ToString("dd-MM-yyyy-HH-mm-ss");
fname = fname + ext;
FileUpload1.SaveAs(Server.MapPath(@"./Images\\") + fname);
String filepath = "~/Images/" + fname;
sq = new SQLDataAccessHelper();
SqlParameter[] param = new SqlParameter[10];
param[0] = new SqlParameter("@username", SqlDbType.NVarChar);
param[0].Value = Convert.ToString(txtUsername.Text);
param[1] = new SqlParameter("@password", SqlDbType.NVarChar);
param[1].Value = Convert.ToString(txtPassword.Text);
param[2] = new SqlParameter("@employeename", SqlDbType.NVarChar);
param[2].Value = Convert.ToString(txtEmployeename.Text);
param[3] = new SqlParameter("@employeecode", SqlDbType.NVarChar);
param[3].Value = Convert.ToString(txtEmployeecode.Text);
param[4] = new SqlParameter("@email", SqlDbType.NVarChar);
param[4].Value = Convert.ToString(txtEmail.Text);
param[5] = new SqlParameter("@img", SqlDbType.Image);
param[5].Value = filepath.ToString();
param[6] = new SqlParameter("@contactno", SqlDbType.NVarChar);
param[6].Value = Convert.ToString(txtContactnumber.Text);
param[7] = new SqlParameter("@usertype", SqlDbType.NVarChar);
param[7].Value = Convert.ToInt32(GetUserTypeId());
param[8] = new SqlParameter("@groupcompanyid", SqlDbType.Int);
param[8].Value = Convert.ToInt32(ddlGroupCompany.SelectedItem.Value);
param[9] = new SqlParameter("@modifiedby", SqlDbType.Int);
param[9].Value = DBNull.Value;
ds = new DataSet();
ds = sq.ExecuteDataSet("usp_InsertUsers", param);
if ((ds != null) && (ds.Tables.Count != 0) && (ds.Tables[0].Rows.Count != 0) && (ds.Tables[0].Rows[0]["Message"].ToString().ToLower() == "yes"))
{
lblMsg.Text = "Data submitted successfully!";
lblMsg.ForeColor = System.Drawing.Color.Green;
ResetCommand();
}
else
{
lblMsg.Text = "Error while submitting data!";
lblMsg.ForeColor = System.Drawing.Color.Red;
ResetCommand();
}
}
catch // error - the connection property has not been initialized//
{
lblMsg.Text = "Error while submitting data!";
lblMsg.ForeColor = System.Drawing.Color.Red;
}
}