473,396 Members | 2,109 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,396 software developers and data experts.

Creating an SQLDB search using a stored procedure

I am trying to create a search page for a database that will display
in a repeater, using a stored procedure. The page_load is fine, and
calls/displays all rows from the db just fine. When I input something
in the search field to display more specific results, the repeater
displays blank. Here are the page_load and btnSearch_click subs:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim CE_DSN As String =
"server=(server);uid=(uid);pwd=(pword);database=(d b)"
Dim connection As New SqlConnection(CE_DSN)
Dim cmdClients As New SqlCommand("stored_proc", connection)

If Not IsPostBack Then
connection.Open()
Dim prmOrderClient As New SqlParameter
cmdClients.CommandType = CommandType.StoredProcedure

With prmOrderClient
.ParameterName = "@order_by"
.SqlDbType = SqlDbType.NVarChar
.Value = " comp.companyName asc"
End With
Dim prmSearchClient As New SqlParameter
With prmSearchClient
.ParameterName = "@search"
.SqlDbType = SqlDbType.NVarChar
.Value = ""
End With

cmdClients.Parameters.Add(prmOrderClient)
cmdClients.Parameters.Add(prmSearchClient)

Dim daclients As New SqlDataAdapter(cmdClients)
Dim dsclients As New DataSet

daclients.Fill(dsclients, "stored_proc")

rpClientList.DataSource = dsclients.Tables("stored_proc")
rpClientList.DataBind()
connection.Close()
End If
End Sub
-------------------------------------------------------------------------------
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnSearch.Click
Dim CE_DSN As String =
"server=(server);uid=(uid);pwd=(pword);database=(d b)"
Dim connection As New SqlConnection(CE_DSN)
Dim cmdClients As New SqlCommand("stored_proc", connection)
Dim prmOrderClient As New SqlParameter
Dim prmSearchClient As New SqlParameter
Dim sql_search As String = ""
'Dim sql_orderby As String
If Len(Trim(txtClient.Text)) > 0 Then
connection.Open()
sql_search = " comp.companyName like '%" & txtClient.Text
& "%'" ' or domain_id.domain like '%" & txtClient.Text & "%' "
With prmOrderClient
.ParameterName = "@order_by"
.SqlDbType = SqlDbType.NVarChar
If rbClientAsc.Checked Then
.Value = " comp.companyName ASC"
Else
.Value = " comp.companyName DESC"
End If
End With
With prmSearchClient
.ParameterName = "@search"
.SqlDbType = SqlDbType.NVarChar
.Value = sql_search
End With
cmdClients.CommandType = CommandType.StoredProcedure
cmdClients.Parameters.Add(prmOrderClient)
cmdClients.Parameters.Add(prmSearchClient)
Dim daclients As New SqlDataAdapter(cmdClients)
Dim dsclients As New DataSet
daclients.Fill(dsclients, "stored_proc")
rpClientList.DataSource = dsclients
rpClientList.DataBind()
connection.Close()
Else : txtClient.Text = "Enter criteria here"
End If
End Sub
-------------------------------------------------------------------------------
When the search button is pressed, the repeater comes back blank.
Also, how would a DSN connection be setup to a remote database?
Thanks in advance.
Nov 19 '05 #1
1 1368
Sorry, the .open( ) and .close( ) calls are outside of the if block

Matthew

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: todd | last post by:
here is a search tool SP I wrote. How many times have you wanted to search all your Stored procs or views (in a database) for a keyword but couldn't!? Well now you can! THis can makes life a...
4
by: Shawn Fletcher | last post by:
Hi, I'm trying to work around a bug that our helpdesk software has. When a new issue is created, it cannot automatically default 2 fields to the value of No like we need it to. I have a...
4
by: Axel | last post by:
Is it possible to write a Stored Procedure that takes a string of search keywords as argument and returns the recordset? At the mo I am passing the WHERE String as argument. I got this...
6
by: mathilda | last post by:
Help! I've been tasked to create a DSN in code and then delete it on close. For security we do not want to leave it in place outside of the application we are implementing.
0
by: billmiami2 | last post by:
Perhaps many of you MS Access fanatics already know this, but it seems that stored procedures and views are possible in Jet. I thought I would leave this message just in case it would help anyone....
1
by: Paul | last post by:
Hi, I wish to be able to add tables to a sql server database at runtime from my asp.net application. As well as creating fields I also wish to be able to create indexes on selected fields and to...
4
by: red vertigo | last post by:
HI All, Can't quite get my head aorund this problem. My knowledge or more importantly my experience of using T-SQL is small and as a consequence my stored procedures are basic. My current...
9
by: jyothi1105 | last post by:
Hi all, Here is some information which could help people who want to create stored procedures and execute them in their program. You can create stored procedures in two ways: Through front end...
2
by: Andy | last post by:
Hi guys I having a problem creating a report in Access 2003 project talking to a SQL database through and ODBC connect. After hours of trying things from Access Help, MSDN and Google I still...
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
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.