Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
adonweb
Starting Member
4 Posts |
Posted - 2008-06-14 : 06:40:32
|
I am creating asp.net 3-tier application where vb class access sql server database and return that data to my aspx page. Stored procedure return a table and an ouptut parameter. I want to bind that table to reapeter control and parameter value to a label text. Repeater control works perfect. But label control shows null value.. I checked that stored procedure returns correct result. Wht i am doing wrong?here is my code...Stored Procedure......... create procedure productsbybrand( @page int, @recs int, @total int OUTPUT, @brandid varchar(10))asset nocount oncreate table #temp( idt int IDENTITY, productid varchar(10), productname varchar(50), images varchar(40), brandname varchar(25), brandlogo varchar(40))insert into #temp(productid,productname,images,brandname,brandlogo)select products.productid, products.productname, products.images, brands.brandname, brands.brandlogofrom products inner join brandson products.brandid=@brandid and brands.brandid=products.brandiddeclare @fr int,@lr intselect @fr=(@page-1)*@recsselect @lr=(@page*@recs+1)select * from #temp where idt>@fr and idt<@lrset @total=(select Count(*) from #temp)select @totalset nocount off----------------------------------------------------------VB ClassImports SystemImports System.CollectionsImports System.ConfigurationImports System.DataImports System.Data.SqlClientNamespace products11 Public class ProductBrand Private _dr as System.Data.SqlClient.SqlDataReader Private _sTotalValue as Integer Public Property dr Get return _dr end get Set _dr = value end set End Property Public Property sTotalValue Get return _sTotalValue end get Set _sTotalValue = value end set End Property end classPublic class get_productsbybrand11 Public function get_productbybrand11(byval page as integer,byval brand as string) As ProductBrand Dim data1 as SqlDataReader Dim totalvalue as Integer Dim con as New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim cmd as New SqlCommand("tester6",con) cmd.CommandType=CommandType.StoredProcedure Dim pagenumber as SqlParameter=cmd.Parameters.Add("@page",SqlDbType.int) Dim psize as SqlParameter=cmd.Parameters.Add("@recs",SqlDbType.int) Dim brandid as SqlParameter=cmd.Parameters.Add("@brandid",SqlDbType.NVarChar,10) Dim total as SqlParameter=new SqlParameter("@total",SqlDbType.int) Dim objProductBrand as ProductBrand=new ProductBrand() total.Direction=ParameterDirection.Output cmd.Parameters.Add(total) pagenumber.value=page psize.value=9 brandid.value=brand con.Open() data1=cmd.ExecuteReader() totalvalue=cmd.Parameters("@total").value objProductBrand.dr = data1 objProductBrand.sTotalValue = totalvalue return objProductBrand end function end classend Namespace---------------------------------------aspx page.....Private sub load_data(myrepeater as Repeater,pageno as integer,brandid as string) Dim total as Integer Dim products as New products11.ProductBrand Dim product as New products11.get_productsbybrand11() products=product.get_productbybrand11(pageno,brandid) myrepeater.DataSource=products.dr total=products.sTotalValue lbl.Text=total myrepeater.DataBind() end sub i tried with arraylist instead of class, but got same result.. |
|
osirisa
Constraint Violating Yak Guru
289 Posts |
Posted - 2008-06-17 : 14:30:37
|
If IsDBNull(drvDataRowView("Name of the Row in your table")) Then lblExample.text = 0I hope this help, this piece of code looks for NULLs in the Database, so you don't get an Error on your page. |
|
|
|
|
|
|
|