473,657 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

data not being retrieved from Access database

72 New Member
Hi there vb genius... I have a problem, i'am currently doing a program that has a database on it. i'am using access database, my problem is the records on my database table doesnt appear on my form...

The scenarion is this.. my database table name is "SUBJECTS" and has a field name "SUBJECT CODES" and "ID" for my primary id.

heres my code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. If rs.State = adStateOpen Then rs.Close
  3.        rs.Open "Select * from [SUBJECTS] where 'PrimaryID Like' = 'ABA0101**'", cnn, adOpenKeyset, adLockOptimistic
  4.  
  5.     While rs.EOF <> True
  6.         For x = 0 To 7
  7.         Text3(x).Text = rs.Fields("SUBJECT CODES").Value
  8.         Next x
  9.      rs.MoveNext
  10.     Wend
  11.  
  12.  
the records must be display in the text box area, but it seems not to be working, i think i'am missing something in my code.. when i try to compile it, it doesnt give any error at all, so it means my database code is correct, i pressume.. but it doesnt do anything at all, it doesnt display all the records in my text boxes. Can someone help me out how can i display it in my text boxes. thank you very much.
May 12 '07 #1
10 1678
Killer42
8,435 Recognized Expert Expert
Hi Darrel.

Looks as though you misunderstood what I said about the Like operator. Is this supposed to return a bunch of records matching a wildcard value, or is "ABA0101**" actually the exact value which you expect to find in them? In other words, is this supposed to find records which start with "ABA0101"?

If it is supposed to match an exact value, then you don't use Like at all, just =.

If it is a wildcard, then you do need to use Like, but your syntax is wrong. Here is the syntax for the two options...

Expand|Select|Wrap|Line Numbers
  1. Your current code...
  2. Select * from [SUBJECTS] where 'PrimaryID Like' = 'ABA0101**'
  3.  
  4. Exact match...
  5. Select * from [SUBJECTS] where PrimaryID = 'ABA0101**'
  6.  
  7. Wilcard search...
  8. Select * from [SUBJECTS] where PrimaryID Like 'ABA0101*'
May 12 '07 #2
darrel
72 New Member
thank you fo rthe reply. but sad to say it doesnt wrong also,, here my code:

Expand|Select|Wrap|Line Numbers
  1. If rs.State = adStateOpen Then rs.Close
  2.        rs.Open "Select * from [SUBJECTS] where 'PrimaryID Like' = 'ABA0101*'", cnn, adOpenKeyset, adLockOptimistic
  3.  
  4.     While rs.EOF <> True
  5.         For x = 0 To 7
  6.         Text3(x).Text = rs.Fields.Item("SUBJECT CODES").Value
  7.  
  8.         Next x
  9.      rs.MoveNext
  10.     Wend
  11.  
yes and it is a wildcard choice, you code is this

Expand|Select|Wrap|Line Numbers
  1.  
  2. "Select * from [SUBJECTS] where PrimaryID Like = 'ABA0101*'", 
  3.  
  4.  
Ive noticed that you you disregard the single quote on the "PrimaryID Like" word and the equal sig, i have followed that but it gives me an error. but when i place a signle quote and equal sign on it. the error is gone but still it doenst display t he records..

i hope you can help me with this please... i'am being desperate.
May 15 '07 #3
Killer42
8,435 Recognized Expert Expert
You can't use both the "=" and the "Like" operator. They are two different types of comparison. Use one or the other, depending on whether you want an exact match or a wildcard "fuzzy" match.

The syntax is...
WHERE FIELD = 'Value'
or
WHERE FIELD LIKE 'WildcardValue'
May 15 '07 #4
darrel
72 New Member
Thank you for that i was able to display the records on my text boxes but now my problem is it only display one record, an it is the last records of my field.

heres my code:

Expand|Select|Wrap|Line Numbers
  1. If rs.State = adStateOpen Then rs.Close
  2.        rs.Open "Select * from [SUBJECTS] WHERE 'PrimaryID LIKE  ABA0101*'", cnn, adOpenKeyset, adLockOptimistic
  3.  
  4.     While rs.EOF <> True
  5.         For x = 0 To 7
  6.         Text3(x).Text = rs.Fields.Item("SUBJECT CODES").Value
  7.         Next x
  8.      rs.MoveNext
  9.     Wend
  10.  
e.i. it only display HUM411T, in all my textboxes and thats not want i want... in my code it must display 8 diffenrent subject code but what i arrived is only one, 8 the same subjects code... and the record that is being displayed is not the one whose i my query HUM411T does not belong to the range of my query in my code now its different...

I hope you can give me some hints... i think am getting into it little by little than you for your patience.
May 15 '07 #5
darrel
72 New Member
Mr. Killer i have figure out whats wrong with my code:

to contribute heres my code

Expand|Select|Wrap|Line Numbers
  1.  
  2. If rs.State = adStateOpen Then rs.Close
  3.        rs.Open "Select * from [SUBJECTS] WHERE 'PrimaryID LIKE  ABA0101*'", cnn, adOpenKeyset, adLockOptimistic
  4.  
  5.   If rs.RecordCount > 0 Then
  6.         For x = 0 To 7
  7.         Text3(x).Text = rs.Fields.Item("SUBJECT CODES").Value
  8.         rs.MoveNext
  9.         Next x
  10.  
  11.  End If
  12.  
  13.  
i just place rs.MoveNext to my For Loop and uses .RecordCount to populate the records..

Again thank you so much for you help and patience i owe you a lot... Hail to you!!!
May 15 '07 #6
Killer42
8,435 Recognized Expert Expert
It's good to see you progressing, but your SQL syntax is still wrong.

Here's your syntax, followed by the correction.

...[SUBJECTS] WHERE 'PrimaryID LIKE ABA0101*'" ...

...[SUBJECTS] WHERE PrimaryID LIKE 'ABA0101*'" ...
May 15 '07 #7
shidec
26 New Member
Just a little explanation

"Select * from [SUBJECTS] WHERE 'PrimaryID LIKE ABA0101*'"
it will display all of your record


"Select * from [SUBJECTS] WHERE PrimaryID LIKE 'ABA0101*'"
it will display record that PrimaryID match the condition, that is 'ABA0101*'
May 15 '07 #8
darrel
72 New Member
Hi i still have problems:

1. the records that are display in my text boxes doesnt change.
2. the records in the text boxes are not being refresh.

Now my question is how will i able to refresh or clear the previous records that are been displayed on my text boxes.

its like this the first records that are in my primary id 'ABA0101*'", are 7 subject codes, and the other one which is 'ABA0102*'" have 9. But when i chose the 'ABA0102*'" records it just add up to the previous records that are been being display and view first. i hope you understand, coz am having difficulty in expalining the scenario..

to be more specific its like this:

'ABA0101*'" - has 7 records on it
'ABA0102*'" - has 9 records on it.

when i run it the records of ABA0101 is being displayed together with ABA0102 thats my problem... i want to eliminate that.

So How can i eliminate, refresh, clear or something like that to the records that are being populated or displayed in my textboxes when i want to view other records. Heres my code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. 'SUBJECT CODE CONNECTION
  3.   If rs.State = 1 Then rs.Close
  4.   rs.Open "Select * from [SUBJECTS] WHERE 'PrimaryID LIKE  ABA0101**'", cnn, adOpenStatic, adLockOptimistic
  5.  
  6.   If rs.RecordCount < 0 Then
  7.             For x = 0 To 7
  8.         txtCode(x).Text = rs.Fields.Item("SUBJECT CODES").Value
  9.  
  10.         rs.MoveNext
  11.  
  12.         Next
  13.  
  14.         For x = 0 To 15
  15.         txtCode(x).Locked = True
  16.         txtSubjects(x).Locked = True
  17.         txtType(x).Locked = True
  18.         txtUnits(x).Locked = True
  19.         Next
  20.   End If
  21.  
  22. 'SUBJECT CODE CONNECTION
  23.  
  24. 'SUBJECT  CONNECTION
  25. If rs.State = adStateOpen Then rs.Close
  26.        rs.Open "Select * from [SUBJECTS] WHERE 'PrimaryID LIKE  ABA0101**'", cnn, adOpenKeyset, adLockOptimistic
  27.  
  28.   If rs.RecordCount > 0 Then
  29.  
  30.         For x = 0 To 7
  31.         txtSubjects(x).Text = rs.Fields.Item("SUBJECT").Value
  32.  
  33.         rs.MoveNext
  34.  
  35.         Next x
  36.  
  37.         For x = 0 To 15
  38.         txtCode(x).Locked = True
  39.         txtSubjects(x).Locked = True
  40.         txtType(x).Locked = True
  41.         txtUnits(x).Locked = True
  42.         Next x
  43.   End If
  44. 'SUBJECT CONNECTION
  45.  
  46. 'TYPE  CONNECTION
  47. If rs.State = adStateOpen Then rs.Close
  48.        rs.Open "Select * from [SUBJECTS] WHERE 'PrimaryID LIKE  ABA0101**'", cnn, adOpenKeyset, adLockOptimistic
  49.  
  50.   If rs.RecordCount > 0 Then
  51.  
  52.         For x = 0 To 7
  53.         txtType(x).Text = rs.Fields.Item("TYPE").Value
  54.  
  55.         rs.MoveNext
  56.  
  57.         Next x
  58.  
  59.         For x = 0 To 15
  60.         txtCode(x).Locked = True
  61.         txtSubjects(x).Locked = True
  62.         txtType(x).Locked = True
  63.         txtUnits(x).Locked = True
  64.         Next x
  65.   End If
  66. 'TYPE CONNECTION
  67.  
  68. 'UNITS  CONNECTION
  69. If rs.State = adStateOpen Then rs.Close
  70.        rs.Open "Select * from [SUBJECTS] WHERE 'PrimaryID LIKE  ABA0101**'", cnn, adOpenKeyset, adLockOptimistic
  71.  
  72.   If rs.RecordCount > 0 Then
  73.  
  74.         For x = 0 To 7
  75.         txtUnits(x).Text = rs.Fields.Item("UNITS").Value
  76.  
  77.         rs.MoveNext
  78.  
  79.         Next x
  80.  
  81.         For x = 0 To 15
  82.         txtCode(x).Locked = True
  83.         txtSubjects(x).Locked = True
  84.         txtType(x).Locked = True
  85.         txtUnits(x).Locked = True
  86.         Next x
  87.   End If
  88. 'UNITS CONNECTION
  89.  
  90.  
Thank you very much, hope you can help me, and i hope you can picture what am trying to say.
May 15 '07 #9
danp129
323 Recognized Expert Contributor
You need to fix your sql query before moving on. The query you are using most likely isn't filtering anything out. Read the last two posts from Killer42 and Shidec again.

It would be nice to know what exactly is in the "Subject Codes". If you open access and look at that field what do the first couple rows have in that field? Need to know exactly what it is, don't truncate it with a wild card when providing this sample.
May 15 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

10
5480
by: sffan | last post by:
I am new to database programming and was curious how others solve the problem of storing encrypted in data in db table columns and then subsequently searching for these records. The particular problem that I am facing is in dealing with (privacy) critical information like credit-card #s and SSNs or business critical information like sales opportunity size or revenue in the database. The requirement is that this data be stored encrypted...
16
3018
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
3
4748
by: Simon Harvey | last post by:
Hi, In my application I get lots of different sorts of information from databases. As such, a lot of information is stored in DataSets and DataTable objects. Up until now, I have been passing around chunks of data in DataTables/DataSets, simply because that was the format that they were in when the data was taken from the database. Now, I know this maybe a pretty silly question with a standard "it depends" answer, but I'm going to...
10
1661
by: Doug Bell | last post by:
Hi, I have an application that has a "Data Access Class" and "User Interface Class". It is for receiving Purchase Order data from one system and pushing processed transactions to another system. The system generally works quite well. Currently the User interface calls for a refresh of data every 15 minutes (selectable) and the Data Access Class connects to the DB and retrieves the
12
457
by: Hugh Welford | last post by:
hi Running an asp site on win/IIs/MSACCESS with a database reaching 45 meg. Responses seem a little slow. Could anyone provide a checklist of things to look at to optimise data access on this platform, or point me in the right direction where I can read up on the subject. Thanks Hugh
17
20786
by: aquablade | last post by:
I have an Oracle 10g R2 database where my ERP transactions reside. I'm using MS Access to grant access to my power users where I use MS Access' Link Tables to provide direct access. I noticed that not all tables in all schema in the database is retrieved by MS Access even if SYSTEM is used to login. It looks like there's an upper limit to the number of tables that's retrieved by MS Access. We need to access all tables in te database. This was...
2
3260
by: Orit | last post by:
Hello . Please find below my questions - I hope some of the ASP.NET experts of this forum will answer to those beginner's questions : My Web site should be able to work with either SQL Server or Access database as following : It will connect first to the Master database (SQL or Access, connection String of this database should be read from the C:\WINDOWS
9
35454
ADezii
by: ADezii | last post by:
One question which pops up frequently here at TheScripts is: 'How do I retrieve data from a Recordset once I've created it?' One very efficient, and not that often used approach, is the GetRows() Method of the Recordset Object. This Method varies slightly from DAO to ADO, so for purposes of this discussion, we'll be talking about DAO Recordsets. The ADO approach will be addressed in the following Tip. We'll be using a Query, consisting of 5...
3
2671
by: James Mills | last post by:
On Thu, Oct 9, 2008 at 2:26 PM, Warren DeLano <warren@delsci.comwrote: Yes it does :) I second this. It's far better to use Data Structures rather than Programming Constructs
4
6255
by: jeet123 | last post by:
hi, i am new to c#. How can i make a form which displays data in a tabular format where the data is retrieved from the database (ms-access) and displayed in that from in table. No matter if the table data is editable or not but yes, the user must be able to print that data. if we can add this feature of if the records displayed exceeds the paper size i.e A4 size paper then the next records should come on next page. i'll be thankful if anybody...
0
8394
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
8306
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
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...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7327
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
4152
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
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
1615
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.