how do dynamic set the value of datetime type of parameter's value from the vb.net application

  • how do I pass dynamic value for the ssrs parameter's value whose type is datetime. when I am sending the

    Textbox.text value after converting and using Convert.ToDateTime(Textbox.text) from my userdefined function REGetParameters1() to SetExecutionParameters(parameters,"en-us") then it throws exception

    my function is defined as:

    'RESerevice is the alias name of ReportExecution2005.asmx

    Private Function REGetParameters1() As REService.ParameterValue()

    _rsExec.Credentials = New System.Net.NetworkCredential("userid", "password", "domainname")

    Dim controls As New ArrayList()

    '.......................................................................................

    '...........get the value from the parameter controls...................................

    '.......................................................................................

    'pnlParam is the Panel name of my application where I have added all the parameter's after retrieving tha parameter

    Dim len As Integer = pnlParam.Controls.Count

    For i As Integer = 0 To len - 1

    If TypeOf pnlParam.Controls(i) Is TextBox Then

    controls.Add(pnlParam.Controls(i))

    End If

    Next

    '.....................................................................................

    '...............add the controls information to parameter info objects................

    '.....................................................................................

    len = controls.Count

    Dim returnvalues As REService.ParameterValue() = New REService.ParameterValue(len - 1) {}

    For i As Integer = 0 To len - 1

    returnvalues(i) = New REService.ParameterValue()

    returnvalues(i).Name = DirectCast(controls(i), TextBox).ID

    Dim check As String

    check = returnvalues(i).Name

    If check.Substring(0, 4) = "Date" Then

    Dim v As String

    v = DirectCast(controls(i), TextBox).Text

    returnvalues(i).Value = (Convert.ToDateTime(v))

    Else

    returnvalues(i).Value = DirectCast(controls(i), TextBox).Text

    End If

    Next

    Return returnvalues

    End Function

    and I am calling this function in my button event to btnViewReport it throws exception after _rsExec.SetExecutionParameters(parameters1123, "en-us")

    mybuttonEvent is as defined:

    Protected Sub btnViewReport_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnViewReport.Click

    Dim path As String = Request.Params("path")

    _rsExec.Url = "http://prakash-pc/ReportServer/ReportExecution2005.asmx"

    ' _rsExec.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials

    'Variables used to render the report;

    Dim result As Byte() = Nothing

    Dim historyID As String = Nothing

    Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"

    Dim encoding As String = Nothing

    Dim mimetype As String = Nothing

    Dim extension As String = Nothing

    Dim warnings As REService.Warning() = Nothing

    Dim streamIDS As String() = Nothing

    'ExecutionHeader execHeader;

    Try

    Dim parameters1123 As REService.ParameterValue() = REGetParameters1()

    _rsExec.Credentials = New System.Net.NetworkCredential("username", "password", "domain")

    If ((parameters1123.Length <> 0) Or (parameters1123.Length = 0)) Then

    ' _rsExec.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials

    _rsExec.LoadReport(path, historyID)

    '_rsExec.SetExecutionCredentials(_rsExec.Credentials)

    _rsExec.Credentials = New System.Net.NetworkCredential("username", "password", "domainname")

    _rsExec.SetExecutionParameters(parameters1123, "en-us")

    _rsExec.Credentials = New System.Net.NetworkCredential("username", "password", "domainname")

    result = _rsExec.Render("html4.0", devInfo, extension, encoding, mimetype, warnings, streamIDS)

    'execInfo = _rsExec.GetExecutionInfo()

    Dim reportName As String = path.Substring(path.LastIndexOf("/") + 1)

    Dim fileName As String = reportName & "." & extension

    'write the report back to the Response object

    Response.Clear()

    Response.ContentType = mimetype

    'add the file name to the response if it is not a web browser format.

    If mimetype <> "text/html" Then

    Response.AddHeader("Content-Disposition", "attachement;filename=" & fileName)

    End If

    Response.BinaryWrite(result)

    End If

    Catch l As SoapException

    Dim t As New TextBox()

    t.Text = l.Detail.OuterXml

    Console.WriteLine(l.Detail.OuterXml)

    End Try

    End Sub

Viewing post 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply