Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Pass object to ConfigurationManager

Author  Topic 

melon.melon
Yak Posting Veteran

76 Posts

Posted - 2009-01-16 : 04:09:22
Hi anybody could help this -

There was this error that say- the left side of an assignment must be a variable, property, or indexer. - for the leaveItem.Employee.ToString() in the Web Form aspx.


tbApprovalDetails has email, dep, approveLevel

In Web.Config -

<add key="debugMode" value="true"/>
<add key="debugEmail" value="email@hotmail.com"/>

In Web Form aspx -

dsLeaveItemDetails = new DataSet();
dsLeaveItemDetails = ldb.GetLeaveItem(leaveItem);

if (Convert.ToBoolean(ConfigurationManager.AppSettings.Get("debugMode")) == true)
{
leaveItem.Employee.ToString() = ConfigurationManager.AppSettings.Get("debugEmail").ToString();
dsApprovalList = ldb.GetApprovalList(leaveItem.Employee.ToString());
}
else
{
dsApprovalList = ldb.GetApprovalForDLL(leaveItem.Employee, 0);
}

In DB form -

public DataSet GetLeaveItem(LeaveApps leaveItem)
{
cm = new SqlCommand("Select * from tbLeaveApp l where l.LeaveID=@LeaveID", cn);
cm.Connection = cn;

SqlParameter p1 = new SqlParameter("@LeaveID", SqlDbType.Int);

cm.Parameters.Add(p1);

cm.Parameters["@LeaveID"].Value = leaveItem.LeaveID;

ds = new DataSet();
da = new SqlDataAdapter(cm);

da.Fill(ds, "LeaveItem");

return ds;
}

public DataSet GetApprovalForDLL(EmployeeDetails employee, int approvalLevel)
{
cm = new SqlCommand("select * from tbApprovalDetails a, tbEmployeeDetails e where a.email=e.email and a.approvalLevel=@approvalLevel and a.dep=@Dept", cn);
cm.Connection = cn;

SqlParameter p1 = new SqlParameter("@approvalLevel", SqlDbType.NVarChar, 5);
SqlParameter p2 = new SqlParameter("@Dept", SqlDbType.NVarChar, 5);

cm.Parameters.Add(p1);
cm.Parameters.Add(p2);

cm.Parameters["@approvalLevel"].Value = approvalLevel.ToString();
cm.Parameters["@Dept"].Value = employee.dep.ToString();

ds = new DataSet();
da = new SqlDataAdapter(cm);

da.Fill(ds, "Approval");

return ds;

}
public DataSet GetApprovalList(EmployeeDetails employee)
{
cm = new SqlCommand("select * from tbApprovalDetails a, tbEmployeeDetails e where a.email=e.email", cn);
cm.Connection = cn;

ds = new DataSet();
da = new SqlDataAdapter(cm);

da.Fill(ds, "Approval");

return ds;

}

Ohmslaw
Starting Member

11 Posts

Posted - 2009-01-16 : 18:56:43
public DataSet GetLeaveItem(LeaveApps leaveItem)
public DataSet GetApprovalList(EmployeeDetails employee)

Have you created a custom Struct for LeaveApps or EmployeeDetails? These must be defined types before passing a value to them.



Ohms...
Go to Top of Page

melon.melon
Yak Posting Veteran

76 Posts

Posted - 2009-01-18 : 21:38:55
Hi Ohms,

if (Convert.ToBoolean(ConfigurationManager.AppSettings.Get("debugMode")) == true)
{
ds = new DataSet();
ldb.OpenConnection();
ds = ldb.GetApprovalList(leaveitem.Employee);
leaveitem.Employee.email= ds.Tables["Approval"].Rows[0]["email"].ToString();
leaveitem.Employee.email= ConfigurationManager.AppSettings.Get("debugEmail");
dsApprovalList = leaveitem.Employee.email;
}

else
{
dsApprovalList = ldb.GetApprovalForDLL(leaveitem.Employee, 1);
}

*Still cannot as there was this leaveItem cannot be converted from string to dataset.
Go to Top of Page

melon.melon
Yak Posting Veteran

76 Posts

Posted - 2009-01-18 : 21:58:08
Have created 2 classes for LeaveApps & EmployeeDetails.
Each have the set & get values.

Within LeaveApps there are all the set & get values with this constructor -

public LeaveApps()
{
employee = new EmployeeDetails();
//leaveDetails = new LeaveDetails();
//
// TODO: Add constructor logic here
//
}

Go to Top of Page
   

- Advertisement -