Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 17th, 2004, 12:45 AM
Registered User
 
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to programmer_kay
Default Help with parameter query having wilcard characte

Hi,
 This is the first time I am trying to implement parameter query using VB.net. I am not sure how to use stored procedures. I have written the following code, but it doesnt work. I get all null values but using the same query on database (ACCESS) gives me some records. Can anyone tell me where I am wrong?.


      Dim a As OleDb.OleDbCommand
      Dim adapter As OleDb.OleDbDataAdapter
      Dim query As String

      query = New String("SELECT mousedata.mouseid, mousedateofbirth.Birthdate" _
      & "FROM mousedata INNER JOIN mousedateofbirth ON mousedata.mouseid = mousedateofbirth.mouseid " _
      & "WHERE ((mousedata.Strain) Like '" & strain & "' & '%' Or " _
      & "(mousedata.Strain) Is Null);")

        a = New OleDb.OleDbCommand()
        a.CommandType = CommandType.Text
        a.Connection = Me.oledbcon()
        a.CommandText = query
        adapter = New OleDb.OleDbDataAdapter(a)
        ds = New DataSet()
        adapter.Fill(ds)
        datagrid1.DataSource = ds


Thanks
 
Old March 17th, 2004, 08:53 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

The line:
Code:
"WHERE ((mousedata.Strain) Like '" & strain & "' & '%' Or " _
Try this instead:
Code:
"WHERE ((mousedata.Strain) Like '" & strain & "%' Or " _
Plus, if the connection is Microsoft Access, shouldn't "*" be used instead of "%"?

Brian Mains
 
Old March 18th, 2004, 03:13 PM
Registered User
 
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to programmer_kay
Default

Hi,
  Thanks for the help. Works!!! I tried with * but I think bcoz I use oledb it needs %.
Thanks
Kailash






Similar Threads
Thread Thread Starter Forum Replies Last Post
Parameter Query Help Normie Access 5 February 19th, 2008 01:50 PM
XSL - Parameter query. Neal XSLT 4 January 24th, 2006 01:27 PM
Parameter Query Teqlump Access 4 November 11th, 2004 07:21 PM
Non query Report Parameter qa BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 July 2nd, 2004 02:49 PM
Parameter Query Ben Access VBA 1 June 27th, 2003 12:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.