Dataset help

Results 1 to 2 of 2

Thread: Dataset help

  1. #1
    Join Date
    Dec 1969

    Default Dataset help

    I&#039;m trying to change my sqldatareader in my sproc into a dataset so that I can sort my datagrid. My code is below and I was hoping someone could look at it and tell me what I&#039;m doing wrong.<BR><BR>Public Function UALGetIssueCategory2(ByVal ddlissuecategory As String, ByVal txtbegindate As String, ByVal txtenddate As String, ByVal sortExpr As String) &#039;As SqlDataReader<BR><BR><BR><BR> &#039; Create Instance of Connection and Command Object<BR> Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("c onnectionString"))<BR><BR> Dim myCommand As New SqlCommand("UALGetIssueCategory2", myConnection)<BR><BR> &#039; Mark the Command as a SP<BR> myCommand.CommandType = CommandType.StoredProcedure<BR><BR><BR> &#039; Add Parameters to SPROC<BR> Dim parameterddlissuecategory As New SqlParameter("@ddlissuecategory", SqlDbType.VarChar, 50)<BR> parameterddlissuecategory.Value = ddlissuecategory<BR> myCommand.Parameters.Add(parameterddlissuecategory )<BR><BR> Dim parametertxtbegindate As New SqlParameter("@txtbegindate", SqlDbType.VarChar, 50)<BR> parametertxtbegindate.Value = txtbegindate<BR> myCommand.Parameters.Add(parametertxtbegindate)<BR ><BR> Dim parametertxtenddate As New SqlParameter("@txtenddate", SqlDbType.VarChar, 50)<BR> parametertxtenddate.Value = txtenddate<BR> myCommand.Parameters.Add(parametertxtenddate)<BR>< BR> Dim parametersortExpr As New SqlParameter("@sortExpr", SqlDbType.VarChar, 50)<BR> parametersortExpr.Value = sortExpr<BR> myCommand.Parameters.Add(parametersortExpr)<BR><BR > Try<BR> Dim dstproducts As DataSet<BR> Dim dadProducts As SqlDataAdapter<BR> dstproducts = New DataSet<BR><BR> dadProducts.Fill(UALGetIssueCategory2)<BR> &#039;Dim AR As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConne ction)<BR><BR> &#039;Return AR<BR><BR> Catch ex1 As Exception<BR> Dim eh As New ExceptionHandler<BR> Dim strUser As String = HttpContext.Current.User.Identity.Name.ToString<BR > Dim strMessage As String = "Exception: EventsDB.GetUserInfo User= " + strUser + " Error Message: " + ex1.Message<BR> eh.LogError(strMessage)<BR> eh.emailError("Exception: UsersDB.vb", strMessage)<BR><BR> Finally<BR><BR> End Try<BR><BR> End Function

  2. #2
    Join Date
    Dec 1969

    Default RE: Dataset help

    Your problem is on this line:<BR><BR>dadProducts.Fill(UALGetIssueCategory2 )<BR><BR>The fill method takes a dataset or a datatable as a parameter. You are passing the name of the function. Should be:<BR><BR>dadProducts.Fill(dstproducts)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts