我在編譯代碼時出錯。它說該數據集不能轉換爲字符串..請幫助我..我已經通過使用SQL存儲過程做到了這一點..我必須獲取保存在主表中的員工姓名以檢索ID,然後ID應檢索離開的詳細信息從請假細節表。將數據集轉換爲VB中的字符串
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
你能包括de錯誤信息嗎? – emecas 2013-03-08 01:51:12
@emecas:謝謝你的倡議..錯誤已經解決.. :) – user1617943 2013-03-08 03:02:24