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


Amit ChoudharyRank #145 · 15.8K reputationPosted Apr 28, 2011, 10:02 PM EDT
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.
Mayur GujrathiRank #666 · 3.6K reputationPosted Apr 28, 2011, 10:08 PM EDT
Dim da As SqlDataAdapter = New SqlDataAdapter("select * from Dis_req_Dtls_MAK", cmd)
Amit ChoudharyRank #145 · 15.8K reputationPosted Apr 28, 2011, 10:39 PM EDT
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 .
Suthish NairRank #92 · 22.8K reputationPosted Apr 28, 2011, 10:41 PM EDT
Mayur GujrathiRank #666 · 3.6K reputationPosted Apr 28, 2011, 10:52 PM EDT
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
Ankit NandekarRank #703 · 3.4K reputationPosted Apr 28, 2011, 11:09 PM EDT
omkar mhaiskar84 reputationPosted Apr 28, 2011, 11:11 PM EDT
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.
Mayur GujrathiRank #666 · 3.6K reputationPosted Apr 28, 2011, 11:17 PM EDT
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
Ankit NandekarRank #703 · 3.4K reputationPosted Apr 28, 2011, 11:24 PM EDT
omkar mhaiskar84 reputationPosted Apr 28, 2011, 11:27 PM EDT
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();
}
}
Mayur GujrathiRank #666 · 3.6K reputationPosted Apr 28, 2011, 11:30 PM EDT
i am filling dataset like this
da.Fill(ds, "pr_ins_upd_reqdtls")
Ankit NandekarRank #703 · 3.4K reputationPosted Apr 28, 2011, 11:37 PM EDT
Mayur GujrathiRank #666 · 3.6K reputationPosted Apr 28, 2011, 11:37 PM EDT
Mayur GujrathiRank #666 · 3.6K reputationPosted Apr 28, 2011, 11:50 PM EDT
now what to do
Ankit NandekarRank #703 · 3.4K reputationPosted Apr 28, 2011, 11:56 PM EDT
Mayur GujrathiRank #666 · 3.6K reputationPosted Apr 29, 2011, 12:00 AM EDT
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
Mayur GujrathiRank #666 · 3.6K reputationPosted Apr 29, 2011, 12:05 AM EDT
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
Ankit NandekarRank #703 · 3.4K reputationPosted Apr 29, 2011, 12:12 AM EDT
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 GujrathiRank #666 · 3.6K reputationPosted Apr 29, 2011, 12:23 AM EDT
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 NandekarRank #703 · 3.4K reputationPosted Apr 29, 2011, 12:30 AM EDT
Mayur GujrathiRank #666 · 3.6K reputationPosted Apr 29, 2011, 12:33 AM EDT
Ankit NandekarRank #703 · 3.4K reputationPosted Apr 29, 2011, 12:35 AM EDT
Mayur GujrathiRank #666 · 3.6K reputationPosted Apr 29, 2011, 12:46 AM EDT
Return Value
0
Ankit NandekarRank #703 · 3.4K reputationPosted Apr 29, 2011, 1:24 AM EDT
omkar mhaiskar84 reputationPosted Apr 29, 2011, 1:28 AM EDT
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.