473,811 Members | 3,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataAdapter returns 0 results, what am I doing wrong?

I'm using ADO .NET to connect to a Microsoft Access database, and
everything so far has been working in my program except one small
problem. I am constructing a query string to search for certain results
from a table, and it does not seem to return the correct results.
Dim dtResults As New DataTable("Sear chResults")

Dim cmdSearchResult s As New OleDb.OleDbComm and(queryString ,
appointments.my Connection)
Dim daSearchResults As New OleDb.OleDbData Adapter(cmdSear chResults)

daSearchResults .Fill(dtResults )

Debug.WriteLine (dtResults.Rows .Count)
Debug.WriteLine (queryString)

where queryString is the string I have constructed. It looks like this:

SELECT Appointments.Ap pointmentID, Appointments.Ap pointmentTime,
Buildings.Build ing, Appointments.Ro omNumber, Appointments.De tails FROM
(Appointments INNER JOIN Buildings ON
Appointments.Bu ildingID=Buildi ngs.BuildingID) INNER JOIN Technicians ON
Appointments.Te chnicianID=Tech nicians.Technic ianID WHERE 1 = 1 AND
Technicians.Tec hnicianName = "Matt" AND Appointments.De tails LIKE "*test*";
When I copy this directly into a query in MS Access it returns the
correct records, however the data adapter in my code returns 0 results.
Whenever I remove the LIKE clause it seems that my queries do return
results back to the data table. Is there something buggy with using the
LIKE clause to send queries through ADO? Any ideas as to what the
problem is anyone?
-Matt
Nov 21 '05 #1
2 1137
Matt,

You might need to use the % character instead of the * character with Like:

AND Appointments.De tails LIKE "%test%";

Also, double-quote delimiters might work, but you might need single-quotes:

AND Appointments.De tails LIKE '%test%';

Kerry Moorman
"Matt Michael" wrote:
where queryString is the string I have constructed. It looks like this:

SELECT Appointments.Ap pointmentID, Appointments.Ap pointmentTime,
Buildings.Build ing, Appointments.Ro omNumber, Appointments.De tails FROM
(Appointments INNER JOIN Buildings ON
Appointments.Bu ildingID=Buildi ngs.BuildingID) INNER JOIN Technicians ON
Appointments.Te chnicianID=Tech nicians.Technic ianID WHERE 1 = 1 AND
Technicians.Tec hnicianName = "Matt" AND Appointments.De tails LIKE "*test*";


Nov 21 '05 #2
Kerry,

Thanks for the reply. On the MS Access side, using the like clause with
% signs does not return the desired results (AND Appointments.De tails
LIKE "%test%"; Basically I want to return results where the Details
field contains the word test (like T-SQL CONTAINS clause). Single
quotes with *'s does not work through ADO, however returns correct
results in MS Access.
Kerry Moorman wrote:
Matt,

You might need to use the % character instead of the * character with Like:

AND Appointments.De tails LIKE "%test%";

Also, double-quote delimiters might work, but you might need single-quotes:

AND Appointments.De tails LIKE '%test%';

Kerry Moorman
"Matt Michael" wrote:

where queryString is the string I have constructed. It looks like this:

SELECT Appointments.Ap pointmentID, Appointments.Ap pointmentTime,
Buildings.Bui lding, Appointments.Ro omNumber, Appointments.De tails FROM
(Appointmen ts INNER JOIN Buildings ON
Appointments. BuildingID=Buil dings.BuildingI D) INNER JOIN Technicians ON
Appointments. TechnicianID=Te chnicians.Techn icianID WHERE 1 = 1 AND
Technicians.T echnicianName = "Matt" AND Appointments.De tails LIKE "*test*";


Nov 21 '05 #3

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

Similar topics

3
7695
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%" sqlDataAdapter1.SelectCommand.Parameters.Add("@style_cd",SqlDbType.VarChar,15); sqlDataAdapter1.SelectCommand.Parameters.Value = txt_style.Text; dataSet11.Clear();
6
1580
by: Geoff Pennington | last post by:
I have a class method that returns a DataAdapter. I want to access the table(s) contained in the DataAdapter. Of course, accessing the DataSets would be good enough, because I could get the tables from there. I can't find a way to do this. Am I missing something? Much obliged.
6
4742
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 that I use to display the data * form load code to populate the controls: DsCampaign1 = New DataSet cmdProActiTmp_Sel.Parameters.Item("@Campaign").Value = _ Trim(txtcampaign.Text())
9
8427
by: Jon | last post by:
Hi, I have a function to fill the data into the dataset: Private Sub LoadSystemDataDB(ByVal m_str As String, ByVal da As _ OleDbDataAdapter, ByVal tbName As String) Dim OleDbConn As New OleDbConnection(OLEDB_CONNECTION_1) OleDbConn.Open() da = New OleDbDataAdapter(m_str, OleDbConn) Dim cmd As New OleDbCommandBuilder(da)
8
2700
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. Example: I have a dataadapter that contains one table with one row. I change the value of the 'FisrtName' column in that row from Jack to John. I call ..update on the dataadapter it goes through fine. Now I change that same column in that same row...
2
13971
by: susan.f.barrett | last post by:
Hi, Despite me being able to type the following in to SQL Server and it updating 1 row: > updatestockcategory 1093, 839 In my code, it is not updating any rows. dataSet = new DataSet();
6
14005
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection = conn da.UpdateCommand.CommandText = "Update tbl1 set fld1 = 'test' where ID = 1" da.Update(tblx) '--tblx/tbl1 not getting updated here.
5
5048
by: George | last post by:
I have set DataAdapter.AcceptChangesDuringUpdate = true; However, I find that I still need to call AcceptChanges on the associated DataTable, DataTable.AcceptChanges(); Has anyone encountered that? Am I not setting this field properly? The following are some of the snippets of the codes which may help explain
1
4468
by: JustinCarmony | last post by:
I'm using a DataAdapter to fill a DataSet to display a list of items in a custom way. I'm not using the GridView or any server controls like that. This is my code: <code> SqlConnection sqlConn = DatabaseControl.Database.GetConnection(Globals.dbConn); SqlCommand cmdTitles = new SqlCommand(); cmdTitles.CommandText = "SelectTitlesByCategory";
0
9731
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10651
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10136
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9208
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6893
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5556
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5697
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4342
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 we have to send another system
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.