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: -
-
If rs.State = adStateOpen Then rs.Close
-
rs.Open "Select * from [SUBJECTS] where 'PrimaryID Like' = 'ABA0101**'", cnn, adOpenKeyset, adLockOptimistic
-
-
While rs.EOF <> True
-
For x = 0 To 7
-
Text3(x).Text = rs.Fields("SUBJECT CODES").Value
-
Next x
-
rs.MoveNext
-
Wend
-
-
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.
10 1678
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... - Your current code...
-
Select * from [SUBJECTS] where 'PrimaryID Like' = 'ABA0101**'
-
-
Exact match...
-
Select * from [SUBJECTS] where PrimaryID = 'ABA0101**'
-
-
Wilcard search...
-
Select * from [SUBJECTS] where PrimaryID Like 'ABA0101*'
thank you fo rthe reply. but sad to say it doesnt wrong also,, here my code: -
If rs.State = adStateOpen Then rs.Close
-
rs.Open "Select * from [SUBJECTS] where 'PrimaryID Like' = 'ABA0101*'", cnn, adOpenKeyset, adLockOptimistic
-
-
While rs.EOF <> True
-
For x = 0 To 7
-
Text3(x).Text = rs.Fields.Item("SUBJECT CODES").Value
-
-
Next x
-
rs.MoveNext
-
Wend
-
yes and it is a wildcard choice, you code is this -
-
"Select * from [SUBJECTS] where PrimaryID Like = 'ABA0101*'",
-
-
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.
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'
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: -
If rs.State = adStateOpen Then rs.Close
-
rs.Open "Select * from [SUBJECTS] WHERE 'PrimaryID LIKE ABA0101*'", cnn, adOpenKeyset, adLockOptimistic
-
-
While rs.EOF <> True
-
For x = 0 To 7
-
Text3(x).Text = rs.Fields.Item("SUBJECT CODES").Value
-
Next x
-
rs.MoveNext
-
Wend
-
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.
Mr. Killer i have figure out whats wrong with my code:
to contribute heres my code -
-
If rs.State = adStateOpen Then rs.Close
-
rs.Open "Select * from [SUBJECTS] WHERE 'PrimaryID LIKE ABA0101*'", cnn, adOpenKeyset, adLockOptimistic
-
-
If rs.RecordCount > 0 Then
-
For x = 0 To 7
-
Text3(x).Text = rs.Fields.Item("SUBJECT CODES").Value
-
rs.MoveNext
-
Next x
-
-
End If
-
-
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!!!
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*'" ...
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*'
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: -
-
'SUBJECT CODE CONNECTION
-
If rs.State = 1 Then rs.Close
-
rs.Open "Select * from [SUBJECTS] WHERE 'PrimaryID LIKE ABA0101**'", cnn, adOpenStatic, adLockOptimistic
-
-
If rs.RecordCount < 0 Then
-
For x = 0 To 7
-
txtCode(x).Text = rs.Fields.Item("SUBJECT CODES").Value
-
-
rs.MoveNext
-
-
Next
-
-
For x = 0 To 15
-
txtCode(x).Locked = True
-
txtSubjects(x).Locked = True
-
txtType(x).Locked = True
-
txtUnits(x).Locked = True
-
Next
-
End If
-
-
'SUBJECT CODE CONNECTION
-
-
'SUBJECT CONNECTION
-
If rs.State = adStateOpen Then rs.Close
-
rs.Open "Select * from [SUBJECTS] WHERE 'PrimaryID LIKE ABA0101**'", cnn, adOpenKeyset, adLockOptimistic
-
-
If rs.RecordCount > 0 Then
-
-
For x = 0 To 7
-
txtSubjects(x).Text = rs.Fields.Item("SUBJECT").Value
-
-
rs.MoveNext
-
-
Next x
-
-
For x = 0 To 15
-
txtCode(x).Locked = True
-
txtSubjects(x).Locked = True
-
txtType(x).Locked = True
-
txtUnits(x).Locked = True
-
Next x
-
End If
-
'SUBJECT CONNECTION
-
-
'TYPE CONNECTION
-
If rs.State = adStateOpen Then rs.Close
-
rs.Open "Select * from [SUBJECTS] WHERE 'PrimaryID LIKE ABA0101**'", cnn, adOpenKeyset, adLockOptimistic
-
-
If rs.RecordCount > 0 Then
-
-
For x = 0 To 7
-
txtType(x).Text = rs.Fields.Item("TYPE").Value
-
-
rs.MoveNext
-
-
Next x
-
-
For x = 0 To 15
-
txtCode(x).Locked = True
-
txtSubjects(x).Locked = True
-
txtType(x).Locked = True
-
txtUnits(x).Locked = True
-
Next x
-
End If
-
'TYPE CONNECTION
-
-
'UNITS CONNECTION
-
If rs.State = adStateOpen Then rs.Close
-
rs.Open "Select * from [SUBJECTS] WHERE 'PrimaryID LIKE ABA0101**'", cnn, adOpenKeyset, adLockOptimistic
-
-
If rs.RecordCount > 0 Then
-
-
For x = 0 To 7
-
txtUnits(x).Text = rs.Fields.Item("UNITS").Value
-
-
rs.MoveNext
-
-
Next x
-
-
For x = 0 To 15
-
txtCode(x).Locked = True
-
txtSubjects(x).Locked = True
-
txtType(x).Locked = True
-
txtUnits(x).Locked = True
-
Next x
-
End If
-
'UNITS CONNECTION
-
-
Thank you very much, hope you can help me, and i hope you can picture what am trying to say.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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
|
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...
|
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
|
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
| |
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...
|
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
|
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...
|
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
|
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...
|
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...
| |
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,...
|
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
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...
| |