473,395 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Return dataset from class library

1
Code at class library :
====================
Public Function SearchItem(ByVal kwrd As String, ByVal schby As String, ByVal type As String) As DataSet
Dim schComm As New SqlCommand("usp_SearchItem", conn)
schComm.CommandType = CommandType.StoredProcedure
Dim param As New SqlParameter("@Keyword", SqlDbType.VarChar, 150)
param.Direction = ParameterDirection.Input
param.Value = kwrd
schComm.Parameters.Add(param)
param = New SqlParameter("@SearchBy", SqlDbType.VarChar, 50)
param.Direction = ParameterDirection.Input
param.Value = schby
schComm.Parameters.Add(param)
param = New SqlParameter("@Type", SqlDbType.VarChar, 50)
param.Direction = ParameterDirection.Input
param.Value = type
schComm.Parameters.Add(param)
'conn.Close()
'conn.Open()
'Dim dr As SqlDataReader = schComm.ExecuteReader
Dim da As New SqlDataAdapter(schComm)
Dim ds As New DataSet("Dset1")
'If Not rdr.HasRows Then
' Throw New Exception("No results found!")
'Else
da.selectcommand=schComm
da.Fill(ds, "Dset1")
'End If
'dr.Close()
conn.Close()
Return ds
End Function

Coding at Search Page :
=====================
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim ib As New ItemBank
Dim dset As New DataSet("Dset1")
dset = ib.SearchItem(txtKwrd.Text, ddSchBy.SelectedItem.Value, ddType.SelectedItem.Value)
dgSearch.DataSource = dset.Tables("Dset1")
dgSearch.DataBind()
lblErr.text = ""
Catch ex As Exception
lblErr.text = ex.Message
End Try
End Sub

Stored Procedure : usp_SearchItem
==================================
ALTER PROCEDURE dbo.usp_SearchItem
@Keyword varchar(150),
@SearchBy varchar(150),
@Type varchar(50)
AS
SELECT * FROM dbo.Items
WHERE Type = @Type AND @SearchBy LIKE '%'+ @Keyword + '%'


cud anyone pls chk tis code...it doesnt show any exception but no results shown in the data grid...

is it poss to use parameter as column name? here i use @searchBy parameter as the column name.

TQ in adv.
Apr 4 '07 #1
0 949

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Andrew Carlson | last post by:
I have a class that performs a few methods on a dataset. That dataset then fills a grid on a form. What I would like to do is to assign a particular dataset to the class at runtime. For...
2
by: JS | last post by:
I'm trying to create a data layer and having problems returning a DataSet from my code that's in a class module. Please forgive me. I'm new to C# (VB'er). I decided to create my data layer in...
3
by: James Morton | last post by:
I am writing a c# windows forms application. I read in an XML file to a dataset for read-only access (by the user and the application logic). This is not an MDI app but has LOTS of seperate...
4
by: Marc Castrechini | last post by:
Forgive any bad terms. New to .Net development My business layer has something similiar to this class Accoun private m_Notes as Note( ' Get Mehod .. end clas
12
by: Marc | last post by:
I have used XMLDataToString = DataSetForXML.GetXml() to get an XML string from a dataset. I am looking for a way to create a dataset from this XML string. I tried...
8
by: GaryDean | last post by:
In an 2.0 asp app I used vs.net 2005 to create a TableAdapter:Dataset in my App_code directory. I also created a new vb class in that same directory. I have two issues: 1. I notice that there...
1
by: Anonieko | last post by:
Here are some of the approaches. 1. Transform DataGrid http://www.dotnetjohn.com/articles.aspx?articleid=36 3. Use the Export approach ...
0
by: Islamegy® | last post by:
I was using WebService and i want to convert this WebService to Class Library so I Removed Inhertance and Attributes with no problems. But When i try to import Exist Dataset or TableAdapters i...
7
by: =?Utf-8?B?TWF4R3J1dmVu?= | last post by:
I have a DLL that implements the Business and Data Layers for a number of different websites. That DLL uses a Strongly Typed DataSet to interface to the Data Source which is SQL Server. There...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.