ورود

View Full Version : اشكال در دريافت خروجي از يك store procedure



akram_k
جمعه 07 مهر 1391, 09:43 صبح
سلام . من توي برنامم واسه جستجو از يك store procedure استفاده كردم كه واسه جستجوي فارسي عبارت like رو هم در اون قرار دادم اما اصلا هيچ اطلاعاتي داخل datagrid view نشون داده نميشه . با اين حال اگه خود store procedure رو execute كنم و همون پارامتر هاي ورودي كه توي برنامم دادم رو مستقيما به store procedure بدم خروجي ها رو نشون ميده .
اين همون store procedure يه كه نوشتم :

ALTER PROCEDURE [dbo].[customer_show](@code int,@firstname nvarchar(50),@lastname nvarchar(50),@city nvarchar (20),@activity nvarchar(50),@justification nvarchar(15),@real int)
as
SELECT real, firstname, lastname, companyname, address, address2, email, website, phone, phone2, cellphone, enable, justification, description, city,
date_insert
FROM dbo.customer

where (dbo.customer.enable=1) and (firstname like N'%'+@firstname+'%' or @firstname is null) and (customer.id=@code or @code=0) and (lastname like N'%'+@lastname +'%' or @lastname is null) and (city like N'%'+@city+'%' or @city is null) and (justification=@justification or @justification is null) and (real=@real or @real=2)


و اين هم اون قسمت از برنامه است كه پارامتر هار و به store procedure ارسال كردم :

public bool show_customer_record(int code, string firstname, string lastname,string city,string justification,string activity, int real, out DataView dv)
{
dv = null;
try
{
set_parameter("customer_show3");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@code", SqlDbType.Int).Value = code;
cmd.Parameters.Add("@firstname", SqlDbType.NVarChar).Value = firstname;
cmd.Parameters.Add("@lastname", SqlDbType.NVarChar).Value = lastname;
cmd.Parameters.Add("@city", SqlDbType.NVarChar).Value = city;
cmd.Parameters.Add("@justification", SqlDbType.NVarChar).Value = justification;
cmd.Parameters.Add("@activity", SqlDbType.NVarChar).Value = activity;
cmd.Parameters.Add("@real", SqlDbType.Bit).Value = real;
da.SelectCommand = cmd;
da.Fill(ds);

da.Fill(ds);
dv = ds.Tables[0].DefaultView;
return true;
}
catch
{
return false;
}
finally
{
dispose_resource();
}
}

كه تابه set_parameter تابعيه كه connection string و ... توش تعريف ميشه
ممنون ميشم هر كدوم از دوستان كه ميتونن منو راهنماييم كنن.