i am calling stored procedure but getting error of table 0 not found
pr_ins_upd_reqdtls is stored procedure name
Dim rowcount As Integer
Dim ds As DataSet = New DataSet
Dim cmd As SqlCommand = New SqlCommand
Dim constr As String = ConfigurationManager.AppSettings("PooledConnectionString")
Dim sqlcon As SqlConnection = New SqlConnection(constr)
cmd.Connection = sqlcon
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "pr_ins_upd_reqdtls"
Dim da As SqlDataAdapter = New SqlDataAdapter("pr_ins_upd_reqdtls", sqlcon)
da.SelectCommand = cmd
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.Fill(ds, "pr_ins_upd_reqdtls")
If (Not (ds.Tables(0).Rows.Count > 0)) Then
rowcount = ds.Tables(0).Rows.Count
'GridView1.Visible = False
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
lblsubheader.Text = "Records Found, " & rowcount & " "
ElseIf ds.Tables(0).Rows.Count > 0 Then
Loading

omkar mhaiskarPosted Apr 29, 2011, 5:28 AM
or also try with only respective qeries if this query is working well then.
tell me.
put normal query in sql studio try with this and tell me.
Ankit NandekarPosted Apr 29, 2011, 5:24 AM
Mayur GujrathiPosted Apr 29, 2011, 4:46 AM
Return Value
0
Ankit NandekarPosted Apr 29, 2011, 4:35 AM
Mayur GujrathiPosted Apr 29, 2011, 4:33 AM
Ankit NandekarPosted Apr 29, 2011, 4:30 AM
Mayur GujrathiPosted Apr 29, 2011, 4:23 AM
in that condition there are again 3 conditions
in only that condition there is select * from Dis_req_Dtls
IF @pa_tholder = 'A'
BEGIN
select * from Dis_req_Dtls
Ankit NandekarPosted Apr 29, 2011, 4:12 AM
f @pa_action ='SEARCHCHK'
begin
IF @pa_tholder = 'P'
BEGIN
select * from Dis_req_Dtls_MAK
where deleted_ind IN (0,4,6)
AND CREATED_BY <> @PA_LOGIN_NAME
AND req_slip_no LIKE CASE WHEN @pa_req_slip_no = '' THEN '%' ELSE @pa_req_slip_no END
AND Boid LIKE CASE WHEN @pa_boid = '' THEN '%' ELSE @pa_boid END
AND case when @pa_req_date = '' then '0' else req_date end = case when @pa_req_date = '' then '0' else @pa_req_date end
END
IF @pa_tholder = 'R'
BEGIN
select * from Dis_req_Dtls_MAK
where deleted_ind = 3
AND req_slip_no LIKE CASE WHEN @pa_req_slip_no = '' THEN '%' ELSE @pa_req_slip_no END
AND Boid LIKE CASE WHEN @pa_boid = '' THEN '%' ELSE @pa_boid END
AND case when @pa_req_date = '' then '0' else req_date end = case when @pa_req_date = '' then '0' else @pa_req_date end
END
IF @pa_tholder = 'A'
BEGIN
select * from Dis_req_Dtls
where deleted_ind = 1
AND req_slip_no LIKE CASE WHEN @pa_req_slip_no = '' THEN '%' ELSE @pa_req_slip_no END
AND Boid LIKE CASE WHEN @pa_boid = '' THEN '%' ELSE @pa_boid END
AND case when @pa_req_date = '' then '0' else req_date end = case when @pa_req_date = '' then '0' else @pa_req_date end
END
end
But in this coditions u r selecting data from Dis_req_Dtls table but this data not coming when u r executing ur storeprocedur may be problem is in ur if conditons bcoz u r not going into if block thats why select * from Dis_req_Dtls not working and u r not getting values from this table so please check u r conditions once again.
Mayur GujrathiPosted Apr 29, 2011, 4:05 AM
i am reapeting again
DECLARE @return_value int,
@pa_error varchar(8000)
EXEC @return_value = [citrus_usr].[pr_ins_upd_reqdtls]
at end like this
SELECT @pa_error as N'@pa_error'
SELECT 'Return Value' = @return_value
Mayur GujrathiPosted Apr 29, 2011, 4:00 AM
at top of stored procedure it is like this
DECLARE @return_value int,
@pa_error varchar(8000)
EXEC @return_value = [citrus_usr].[pr_ins_upd_reqdtls]
at end like this
SELECT @pa_error as N'@pa_error'
SELECT 'Return Value' = @return_value
after executing stored procedure as u said i come with result
Return Value
0
@pa_error
null
i think return value means no of rows and it is coming 0 after doing this
is'nt it please reply now what to do
Ankit NandekarPosted Apr 29, 2011, 3:56 AM
Mayur GujrathiPosted Apr 29, 2011, 3:50 AM
now what to do
Mayur GujrathiPosted Apr 29, 2011, 3:37 AM
Ankit NandekarPosted Apr 29, 2011, 3:37 AM
Mayur GujrathiPosted Apr 29, 2011, 3:30 AM
i am filling dataset like this
da.Fill(ds, "pr_ins_upd_reqdtls")
omkar mhaiskarPosted Apr 29, 2011, 3:27 AM
this is the sample code for to get values in the datatable. do not use same as it is. just create your code in following manner. this code is in c# just convert it in vb.net.
datatable dt=new datatable();
try
{
connectionString = ConfigurationManager.ConnectionStrings["testApplication"].ConnectionString;//connection string.
_connection = new SqlConnection(connectionString); //connection name
_command = new SqlCommand();//sql command
_connection.Open();//connection open
_command.CommandText = pName;
_command.CommandType = CommandType.StoredProcedure;
_command.Connection = _connection;
//add your command parameter here.
dt.Load(_command.ExecuteReader());
}
catch
{
}
finally
{
_command.Dispose();
_connection.Close();
}
}
Ankit NandekarPosted Apr 29, 2011, 3:24 AM
Mayur GujrathiPosted Apr 29, 2011, 3:17 AM
if @pa_action ='SEARCHCHK'
begin
IF @pa_tholder = 'P'
BEGIN
select * from Dis_req_Dtls_MAK
where deleted_ind IN (0,4,6)
AND CREATED_BY <> @PA_LOGIN_NAME
AND req_slip_no LIKE CASE WHEN @pa_req_slip_no = '' THEN '%' ELSE @pa_req_slip_no END
AND Boid LIKE CASE WHEN @pa_boid = '' THEN '%' ELSE @pa_boid END
AND case when @pa_req_date = '' then '0' else req_date end = case when @pa_req_date = '' then '0' else @pa_req_date end
END
IF @pa_tholder = 'R'
BEGIN
select * from Dis_req_Dtls_MAK
where deleted_ind = 3
AND req_slip_no LIKE CASE WHEN @pa_req_slip_no = '' THEN '%' ELSE @pa_req_slip_no END
AND Boid LIKE CASE WHEN @pa_boid = '' THEN '%' ELSE @pa_boid END
AND case when @pa_req_date = '' then '0' else req_date end = case when @pa_req_date = '' then '0' else @pa_req_date end
END
IF @pa_tholder = 'A'
BEGIN
select * from Dis_req_Dtls
where deleted_ind = 1
AND req_slip_no LIKE CASE WHEN @pa_req_slip_no = '' THEN '%' ELSE @pa_req_slip_no END
AND Boid LIKE CASE WHEN @pa_boid = '' THEN '%' ELSE @pa_boid END
AND case when @pa_req_date = '' then '0' else req_date end = case when @pa_req_date = '' then '0' else @pa_req_date end
END
end
@omkar can you give code for using data table
omkar mhaiskarPosted Apr 29, 2011, 3:11 AM
for trial and error basic use datatable instead of dataadaptor. then you will get perticullar table info at a time.
then you will get what happen exacatly there.
Ankit NandekarPosted Apr 29, 2011, 3:09 AM
Mayur GujrathiPosted Apr 29, 2011, 2:52 AM
table 0 not found
@ suthish sir
while posting it first time problem was occured , and posted it again without wathing wheather it is posted or not
Suthish NairPosted Apr 29, 2011, 2:41 AM
Amit ChoudharyPosted Apr 29, 2011, 2:39 AM
da.Fill(ds, "pr_ins_upd_reqdtls")
this will surely work.. keep the order of the statements same.. just put the Initialization with its call to FILL method .
Mayur GujrathiPosted Apr 29, 2011, 2:08 AM
Dim da As SqlDataAdapter = New SqlDataAdapter("select * from Dis_req_Dtls_MAK", cmd)
Amit ChoudharyPosted Apr 29, 2011, 2:02 AM
Please put a check before the statement "If (Not (ds.Tables(0).Rows.Count > 0)) Then" for ds.Tables(0) is not null.
also update this statement..
Dim da As SqlDataAdapter = New SqlDataAdapter("pr_ins_upd_reqdtls", sqlcon) pass Command object instead of sqlcon here..
Thanks.