Mayur  Gujrathi

Mayur Gujrathi

  • 409
  • 3.9k
  • 1m

About calling of stored procedure

Apr 29 2011 12:55 AM
i have one simple problem but i am not getting syntax
i am calling procedure in this way

Dim constr As String = ConfigurationManager.AppSettings("PooledConnectionString")
        Dim sqlcon As New SqlConnection(constr)
        Dim da As SqlDataAdapter
        Dim ds As New DataSet()
        Dim cmd As SqlCommand
        cmd = New SqlCommand("pr_ins_upd_reqdtls", sqlcon)
        cmd.Connection = sqlcon
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Parameters.Clear()
        Dim Var_StrLoginame As String = Session("LoginName")
        cmd.Parameters.AddWithValue("@pa_action", "SEARCHCHK")
        cmd.Parameters.AddWithValue("@pa_tholder", ddlselect.Value)
        If (filter.Value = "I") Then
            cmd.Parameters.AddWithValue("@pa_boid", hdfilter.Value)
            cmd.Parameters.AddWithValue("@pa_req_slip_no", "")
            cmd.Parameters.AddWithValue("@pa_req_date", "")
        ElseIf (filter.Value = "S") Then
            cmd.Parameters.AddWithValue("@pa_boid", "")
            cmd.Parameters.AddWithValue("@pa_req_slip_no", hdfilter.Value)
            cmd.Parameters.AddWithValue("@pa_req_date", "")
        ElseIf (filter.Value = "D") Then
            cmd.Parameters.AddWithValue("@pa_boid", "")
            cmd.Parameters.AddWithValue("@pa_req_slip_no", "")
            Dim pdate As Date
            pdate = ClsDate.GetFormatedDate(hdfilter.Value, "DD/MM/YYYY")
            cmd.Parameters.AddWithValue("@pa_req_date", pdate)
        End If
        cmd.Parameters.AddWithValue("@pa_login_name", Var_StrLoginame)
        'parameters not in use
        cmd.Parameters.AddWithValue("@pa_id", 0)
        cmd.Parameters.AddWithValue("@pa_boname", "")
        cmd.Parameters.AddWithValue("@pa_sholder", "")
        cmd.Parameters.AddWithValue("@pa_chk_yn", 0)
        cmd.Parameters.AddWithValue("@pa_rmks", "")
        cmd.Parameters.Add("@pa_error", SqlDbType.VarChar, 8000)
        cmd.Parameters("@pa_error").DbType = DbType.AnsiString
        cmd.Parameters("@pa_error").Direction = ParameterDirection.Output


        da = New SqlDataAdapter()
        da.SelectCommand = cmd
        da.Fill(ds, "pr_ins_upd_reqdtls")
        If ((ds.Tables(0).Rows.Count > 0)) Then
            GridView1.DataSource = ds
            GridView1.DataBind()
            Dim rowcount As Integer
            rowcount = ds.Tables(0).Rows.Count
            lblsubheader.Text = "Records Found,  " & rowcount & " "

but it is giving error table 0 not found

Answers (1)