473,473 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SQL Parameters

TS
I configured a data adapter and a dataset to connect to a SQL database. Also
I wrote a code to setup a currency manager for data binding on the form load
event.
On a button click event, I want to show the client's data based on the
client's first and last name typed in 2 text boxes (filtering data based on
those 2 text boxes). I used the following code for the event click, but got
an error message " An SqlParameter with ParameterName '@SHR_LAST_NAME' is not
contained by this SqlParameterCollection". Please Help!!

Dim irecords As Integer
Dim bloading As Boolean
If TextBox1.Text <> "" And TextBox2.Text <> "" Then
bloading = True

SqlDataAdapter_Preven.SelectCommand.Parameters("@S HR_LAST_NAME").Value =
TextBox1.Text

SqlDataAdapter_Preven.SelectCommand.Parameters("@S HR_FIRST_NAME").Value =
TextBox2.Text
PrevenClientsDataSet._Table.Clear()
irecords = SqlDataAdapter_Preven.Fill(PrevenClientsDataSet)

If irecords = 0 Then
MessageBox.Show("Child Name Not Found.", "Entry Error")
TextBox1.Focus()
Else
TextBox1.Focus()
End If
bloading = False

Else
MessageBox.Show("You must enter a valid Child Name.", "Data
Error")
TextBox1.Focus()
End If

End Sub

--
TS
Nov 21 '05 #1
1 1443
TS wrote:
I configured a data adapter and a dataset to connect to a SQL database. Also
I wrote a code to setup a currency manager for data binding on the form load
event.
On a button click event, I want to show the client's data based on the
client's first and last name typed in 2 text boxes (filtering data based on
those 2 text boxes). I used the following code for the event click, but got
an error message " An SqlParameter with ParameterName '@SHR_LAST_NAME' is not
contained by this SqlParameterCollection". Please Help!!

Dim irecords As Integer
Dim bloading As Boolean
If TextBox1.Text <> "" And TextBox2.Text <> "" Then
bloading = True

SqlDataAdapter_Preven.SelectCommand.Parameters("@S HR_LAST_NAME").Value =
TextBox1.Text

SqlDataAdapter_Preven.SelectCommand.Parameters("@S HR_FIRST_NAME").Value =
TextBox2.Text
PrevenClientsDataSet._Table.Clear()
irecords = SqlDataAdapter_Preven.Fill(PrevenClientsDataSet)

If irecords = 0 Then
MessageBox.Show("Child Name Not Found.", "Entry Error")
TextBox1.Focus()
Else
TextBox1.Focus()
End If
bloading = False

Else
MessageBox.Show("You must enter a valid Child Name.", "Data
Error")
TextBox1.Focus()
End If

End Sub


dim Parm as new SqlParamter("@SHR_LAST_NAME", sqldbtype.varchar)
SqlDataAdapter_Preven.SelectCommand.Parameters.Add (Parm)
SqlDataAdapter_Preven.SelectCommand.Parameters("@S HR_LAST_NAME").Value =
TextBox1.Text

or

dim Parm as new SqlParamter("@SHR_LAST_NAME", TextBox1.Text)
SqlDataAdapter_Preven.SelectCommand.Parameters.Add (Parm)
Nov 21 '05 #2

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

Similar topics

7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
2
by: Mark | last post by:
I created a test to check the execution time difference between executing a SQL Server stored procedured using explicit parameters versus not. In one case I created new SqlParameters in the code,...
4
by: Tim::.. | last post by:
Can someone tell me a better way or give me a link that shows a better way to create large numbers of SQL parameters... Example... A better way to write this code! <code> Sub...
14
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
2
by: Hexman | last post by:
Hello All, Well I'm stumped once more. Need some help. Writing a simple select and update program using VB.Net 2005 and an Access DB. I'm using parameters in my update statement and when trying...
12
by: pamelafluente | last post by:
Hi guys, In the past I have used several time optional parameters in my function. But Now I am more inclined to think that they are more dangerous than useful, and probably better to be...
1
by: John Kotuby | last post by:
Hi all, I am working on porting an application from VB6 to VB.NET 2003 and am running into some problems. When declaring and populating the parameters for a SQL Stored Procedure by using the...
0
by: Xah Lee | last post by:
In this article, i explain how the use of bit masks is a hack in many imperative languages. Often, a function will need to take many True/False parameters. For example, suppose i have a function...
2
by: Jared Grant | last post by:
I am trying to find the value from some output parameters from a stored procedure. I have tried several different methods but somehow cannot get it to work. here is my source code: dim dr as...
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
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
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
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.