我在编译代码时出错。它说数据集不能转换为字符串..请帮助我..我已经使用 SQL 存储过程完成了这个..我必须获取保存在主表中的员工姓名来检索 ID,然后 ID 应该检索休假详细信息从休假详细信息表中。
Public Shared Function GetEmpID(ByVal EmpName As String) As DataSet
Dim db As Database = DatabaseFactory.CreateDatabase(HttpContext.Current.Session("CompanyID").ToString) ' TO Get Database Connection
Dim dbCommand As DbCommand = db.GetStoredProcCommand("spRetrieveEmpID") ' Stored Procedure to Execute
db.AddInParameter(dbCommand, "EmployeeName", DbType.String, EmpName) ' Parameter for Stored Procedure
Return db.ExecuteDataSet(dbCommand) ' Execute Stored Procedure
End Function
Public Shared Function EmpLeaveDetails(ByVal EmployeeID As String) As DataSet
Dim db As Database = DatabaseFactory.CreateDatabase(HttpContext.Current.Session("CompanyID").ToString) ' TO Get Database Connection
Dim dbCommand As DbCommand = db.GetStoredProcCommand("spHRLeaveEntitlement") ' Stored Procedure to Execute
db.AddInParameter(dbCommand, "EmployeeID", DbType.String, EmployeeID) ' Parameter for Stored Procedure
Return db.ExecuteDataSet(dbCommand) ' Execute Stored Procedure
End Function
这是我的 leave.aspx.vb 代码
Private Sub ddlEmpName_SelectedIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles ddlEmpName.SelectedIndexChanged
EmployeeID = TESTING.GetEmpID(ddlEmpName.Text)
If ds.Tables(0).Rows.Count > 0 Then
dgLeaveDetails.DataSource = ds
dgLeaveDetails.DataBind()
End If
ds1 = TESTING.EmpLeaveDetails(EmployeeID)
dgLeaveDetails.DataSource = ds1
ddlEmpName.SelectedIndex = -1
dgLeaveDetails.Rebind()
End Sub