473,513 Members | 7,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parameters for DataAdapter

I'm creating a simple search for Members, with possible 4 search parameters:
Name, SSN, DOB, SEX, but (just beginning ASP.NET/VB.NET) I'm fearing that I
will need to create a dataadapter for every possible combination of fields
entered to eliminate a blank parameter.

Does a parameterized DataAdapter automatically take care of this so I can
use the following SQL without having to worry about blank textboxes?:

SELECT * From Membership WHERE
Name = @txtName AND
SSN like @txtSSN AND
DOB like @txtDOB AND
SEX like @txtDOB

Presently, in my Access application, I've had to write a separate strSQL for
each possible combination as to avoid creating a SQL statement with a blank
parameter.

Thanks so much for anything to help with this...
Dec 16 '05 #1
2 1325
Jonefer,

AFAIK it does not, I wish it was there.

In addition, because of the fact that it is Access, do you have in my
opinion as well not much alternatives. Be aware that in OleDB the parameter
name does nothing, it is the sequence that they are declared which counts in
OleDB.

(A ? does as much as a name)

http://www.vb-tips.com/default.aspx?...3-eb8b44af0137

Although you are very much welcome here, a better newsgroups for this kind
of questions is.

microsoft.public.dotnet.framework.adonet

I hope this helps,

Cor
Dec 16 '05 #2
Why not build the string when you require it? I'm assuming that you're
getting the values from a text box or something similar. Not quite proper
code but it gives you the idea

Function BuildQuery(txtName, txtSin, txtDOB, txtSex) as string
DIM QryStr as String = "SELECT * FROM MEMBERSHIP WHERE "
DIM QrySIN, QryDOB, QrySex as string

if txtName <> "" Then QryStr = QryStr & "NAME = @txtName"
if txtSIN <> "" Then
if QryName <> "" then QrySIN = " AND "
QrySIN = QrySIN & "SSN = @txtSSN"
enf if

'similar conditions
Return QryStr
End

May not be pretty, but I've used it before

"jonefer" wrote:
I'm creating a simple search for Members, with possible 4 search parameters:
Name, SSN, DOB, SEX, but (just beginning ASP.NET/VB.NET) I'm fearing that I
will need to create a dataadapter for every possible combination of fields
entered to eliminate a blank parameter.

Does a parameterized DataAdapter automatically take care of this so I can
use the following SQL without having to worry about blank textboxes?:

SELECT * From Membership WHERE
Name = @txtName AND
SSN like @txtSSN AND
DOB like @txtDOB AND
SEX like @txtDOB

Presently, in my Access application, I've had to write a separate strSQL for
each possible combination as to avoid creating a SQL statement with a blank
parameter.

Thanks so much for anything to help with this...

Dec 16 '05 #3

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

Similar topics

3
7680
by: Mike D | last post by:
What am I doing wrong? I want to be able to add parameters to my WHERE clause in my sqlDataAdapter. I also want to use LIKE. (ie. style_cd like "%123%" ...
1
2066
by: Eugene Turin | last post by:
I'm writing a simple app that acts with simple DBF table via ODBCAdapter. I've got the idea of working with DataGrid, DataDet and DataAdapter. I connect to my Adapter DeleteCommand and AddComand....
1
1522
by: James | last post by:
I have an sp with paramaters like this: ALTER PROCEDURE dbo.SomeProc ( @SortBy varchar(50) = NULL @ShowComplete bit = 0 @StaffID int = NULL ) AS DECLARE @SQL varchar(2500) SET @SQL =
3
8814
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I...
2
3699
by: John Smith | last post by:
i dont understand how to use `em all those @id ... what they have to do with a datagrid bound to a dataset filled by an adapter TIA
1
1603
by: Lucas Tam | last post by:
Hi all, What is the best way to pass parameters to an event? I have a dataadapter.update that fires, and I am capturing the RowUpdated event. How do I pass some custom pamaeters into this...
6
4731
by: Jack | last post by:
I have the following: * An OLEDBCommand with command text "SELECT CAMPAIGN, DAY_OUT WHERE (CAMPAIGN LIKE '@campaign')" * A DataAdapter that point the select to the above command * A data grid...
6
854
by: John | last post by:
Hi I have the following code; Public DA(3) As Object DA(1) = New Class1 DA(2) = New Class2 Is there a way to pass the class types as parameter to a sub as below;
4
2193
by: melryin | last post by:
Hi, I'm a newbie in C#, I wrote an OLEDb query with positioned parameter. It seems not working. Can anyone please point out where I've done wrong? Thanks in advance. Here is my code: using...
0
7153
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
7373
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
7432
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...
1
7094
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
5677
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,...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
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
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
452
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.