Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 16th, 2008, 05:24 AM
Authorized User
 
Join Date: Feb 2007
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL LIKE Multiple Conditions

Im having some trouble using the SQL Like command with multiple conditions

where as the first line of code works with one condition the second one doesnt even thought it doesnt return any errors

Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM chdetails WHERE chname LIKE '%" & txtFRname.Text & "%'", myConnection)

Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM chdetails WHERE (chname LIKE '%" & txtFRname.Text & "%') AND (chsurname LIKE '%" & txtFRsname.Text & "%') AND (chDOB = '%" & txtFRdob.Text & "%')", myConnection)


Full Code is below

        Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data source =" & Server.MapPath("db2.mdb")
        Dim myConnection As OleDbConnection = New OleDbConnection
        myConnection.ConnectionString = connString
        ' create a data adapter

        Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM chdetails WHERE (chname LIKE '%" & txtFRname.Text & "%') AND (chsurname LIKE '%" & txtFRsname.Text & "%') AND (chDOB = '%" & txtFRdob.Text & "%')", myConnection)

        ' create a new dataset

        Dim ds As DataSet = New DataSet
        ' fill dataset

        da.Fill(ds, "chdetails")
        ' Attach DataSet to DataGrid

        GridView1.DataSource = ds
        GridView1.DataBind()

        MultiView1.SetActiveView(child)

Where am I going wrong

Reply With Quote
  #2 (permalink)  
Old April 16th, 2008, 06:24 AM
Authorized User
 
Join Date: Feb 2007
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found it !

Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM chdetails WHERE (chname LIKE '%" & txtFRname.Text & "%') AND (chsurname LIKE '%" & txtFRsname.Text & "%') AND (chDOB = '" & txtFRdob.Text & "')", myConnection)


instead of


Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM chdetails WHERE (chname = '" & txtFRname.Text & "') AND (chsurname = '" & txtFRsname.Text & "') AND (chDOB = '" & txtFRdob.Text & "')", myConnection)


look very closely

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
using multiple conditions in sql loader elygp Oracle 0 October 9th, 2008 10:21 PM
IIf Function - Multiple conditions carrie09 Access 2 June 13th, 2007 10:27 AM
Multiple conditions austinf XSLT 1 May 5th, 2006 02:55 AM
Multiple conditions austinf XSLT 1 May 5th, 2006 02:38 AM
Multiple If..Else conditions executed problem DavidGreen C# 2 March 16th, 2005 09:26 AM



All times are GMT -4. The time now is 08:04 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.