190 Replies - 8743 Views - Last Post: 23 June 2011 - 04:46 PM
#1
Q re: Random Access Files, data-aware obj...
Posted 16 February 2011 - 06:35 PM
I am using a series of random access files, to orchestrated a relatively linked flat file database. I hate MSAccess as I have had serious issues with it in the past. However when I am attempting to use say a combo box, I would like the data from the test.rnd file (the one that holds the information that I want loaded in the combo box) but the data X properties wont allow me to use the random acces files to be directly linked to the combo box, and when i try to use a data control object (e.g. Data1) and set it to the "text;" setting for the connection, and the database name "test.rnd" it gives me an error with the Jet connector, "Couldn't Find Installable ISAM", when i attempt to use the ODBC connector, it also gives an error, "Invalid Argument"...
Is there a way to either to get the data control to work with my random access files? Or is there a way to get my random access files to interact with data-aware, and or data-bound controls? With out using some other form of databases...
Most of my random access files only have a no more than 200 records, and thats only one, most have less than 50 records... other db's have too much "overhead" to deal with for what i am doing... which basicly is fill controls with the data from the random access files, based on the selection (which are linked to other relevant RA files to populate them with the needed information... the reason is that i had been working with sequential files, and am now trying to eliminate the extra files that aren't needed a with the random access files because they are set in record sets... For example of what i want to do....
I have a RA file named Speaker.rnd, this contains SpkId, SpkName Fields... Then there is a RA file named Talks.rnd, this contains the fields, TlkId, TlkNumber, TlkCategory, and TlkTheme
when you set the speaker with a set number of talks it creates a new random access file with the following fields... TlkId, TlkPosition; This will open the Talks.rnd and will pull the TlkTheme field and set it to a label when the speaker and the talk number is selected... This is saving a pretty complex explanation, but its what i can say to try to explain the basic idea, since with seq files, i would have at least 6 steps and three more files to deal with...
Any help or suggestions should be appreciated, i haven't really found much on my Google searched on what to use to get what i would like done done...
Jesse Fender
Replies To: Q re: Random Access Files, data-aware obj...
#2
Re: Q re: Random Access Files, data-aware obj...
Posted 18 February 2011 - 09:00 AM
#3
Re: Q re: Random Access Files, data-aware obj...
Posted 19 February 2011 - 01:40 PM
BobRodes, on 18 February 2011 - 08:00 AM, said:
The problem is that i am still working out the code.... it seems that Random Access Files, are not compatible with the datacontrol. It however has been proving to be much more difficult to deal with than i had hoped it would have been... in my mind, the random access files would provide a simple way for me to store and retreive the information stored in them to be called up and placed with in the programs forms... there are three programs that i want to convert from a severely crippling file system "database" which were bulky and could be edited by opening the files and editing them (Not want i want) because it needs to be used to direct to the right files... in their case directories... the issues wityh this should be obvious.... and the reason that i dont want to go with a full on db software, is that it has given me issues in the past where the database was empty and it freaked out... it was just plain old nightmare... However i can create and use random access files to tuck the information into, and that part works great, the part i am having issues with is the reading them into the form controls... I will work with the code and hopefuly post it later today(or evening) at the latest next saturday...
Jesse Fender
#4
Re: Q re: Random Access Files, data-aware obj...
Posted 19 February 2011 - 10:34 PM
The idea to use ADO data control almost worked, the adodc1 control has been set with the information i know if, but it wont read the information from the file... i cant get it to work...
Settings form properties that have been modified:
CommandType= 1-adCmdText ConnectionString=FILE NAME=C:\Program Files\Microsoft Visual Studio\VB98\Test.txt
The rest is all unknown to me, When the form loads it sets the adodc1 disabled so that it cant do anything. likely due to the fact i really dont know how to get it to read the Test.txt file:
General fields of Test.txt:
Position Id(Int): Territory or Talk Number(Int): Name(Str*25): Date Out(Str*12): Date In(Str*12):
The test.txt file has several records in it. And another test program (Mentioned above) works with the file directly using Command Buttons and the file reads writes and updates pretty flawlessly. But that isn't a data control item, and my books i have aren't much help as they tell me to setup a db system that vb uses, and that is not what i want to do...
Needed records: most RAF's will contain less than 20 records. The largest will likely not soon exceed 200 records. How do i connect the ADO Data Control to my RAFiles so that my controls (List and combo boxes...) can have access to the data in the RAFiles...
I have not much more information to present to you guys...
Can it be done? if so what do i need to do to get the things working? If these data controls don't work what db system would have the least overhead and required programming and maintainability and relative ease of implementation of this system for my three and maybe more programs to store their small data loads in the database...
Jesse Fender
#5
Re: Q re: Random Access Files, data-aware obj...
Posted 21 February 2011 - 12:05 AM
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtFilesFolder\;Extended Properties="text;HDR=Yes;FMT=Delimited";Also, you'll probably want to index your recordset.
As for sending data to a dll and having it do the processing, that's the way to do it. Data tier components are commonplace.
So, you're on the right track, except with your insistence on using that horrible Data Control. Data binding in VB6 is considered iffy.
#6
Re: Q re: Random Access Files, data-aware obj...
Posted 21 February 2011 - 12:15 AM
BobRodes, on 20 February 2011 - 11:05 PM, said:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtFilesFolder\;Extended Properties="text;HDR=Yes;FMT=Delimited";Also, you'll probably want to index your recordset.
As for sending data to a dll and having it do the processing, that's the way to do it. Data tier components are commonplace.
So, you're on the right track, except with your insistence on using that horrible Data Control. Data binding in VB6 is considered iffy.
Well Bob, the information you have given me should work i think I will give it a try tuesday, or later tonight Thank you... I will keep that in mind as I work on adding the RAF's to the programs, the data items were just to look an read stuff to the controls...
I have been working on building the dll file to auto index, based on certain needed qualities, and all that goodness, And I can use my created data control made from command buttons to deal with the functions with in the files... I even have a nifty sort function that will sort the index for me
Many thanks again for the information I will let you know if it works.
Jesse Fender
#7
Re: Q re: Random Access Files, data-aware obj...
Posted 21 February 2011 - 01:34 PM
BobRodes, on 20 February 2011 - 11:05 PM, said:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtFilesFolder\;Extended Properties="text;HDR=Yes;FMT=Delimited";Also, you'll probably want to index your recordset.
As for sending data to a dll and having it do the processing, that's the way to do it. Data tier components are commonplace.
So, you're on the right track, except with your insistence on using that horrible Data Control. Data binding in VB6 is considered iffy.
OK heres what is happening... I am not sure of what to do with my ADODC1 control. it is about to have fully pissed me off... I cannot get the information from the RAF to the form controls(e.g. combo boxes, listboxes, and textboxes...) the ADO control is an option, but when i go to set the field param it errors with the "Installable ISAM" couldn't be found... The test program opens and ADODC is disabled.
I tried the ADODC properties, and built the connection string, but this failed to fix the issue.
This is A F@*#$& nightmare!!!!!
Below is a copy of the test.text file so that you may look at the formatting and see if you can get your vb to connect to it... if you get it to do so, then i will try to get mine to work, again... but i am very quickly losing my cool with this...
The other option i have been trying to get to work is....:
If FSO.FileExists("Test.txt") = True Then
I = 0
Dim test1 As String, test2 As String, test3 As String, test4 As String, test5 As String, J As Integer
J = 1
Open "Test.txt" For Random As #255 Len = 54
Do Until EOF(255)
Get #255, J, TerrTest
test1 = TerrTest.IdKey
test2 = TerrTest.TerrNum
test3 = TerrTest.PubName
test4 = TerrTest.CODate
test5 = TerrTest.CIDate
Combo1.AddItem test3, I
Loop
Close #255
End If
Which leads to an epic FAIL where my vb locks up...and i have to restart it... if there is a way to get this thing working i can work from there... this is my alternate option to a data contorl, or ADOC.
Jesse Fender
Attached File(s)
-
Test.txt (153bytes)
Number of downloads: 109
#8
Re: Q re: Random Access Files, data-aware obj...
Posted 21 February 2011 - 02:16 PM
I am sorry Bob is i came off as snapping at you in my last two posts... It wasn't meant that way...
What was the error???
I forgot to increment the J position which was like causing the system to freak, but now it is working... all is good, and I will be asking on more questions... but that will be in another thread... and after i try to find the answer in google.... you will likely hear from me soon
Thanks Bob for your help.
Jesse Fender
#9
Re: Q re: Random Access Files, data-aware obj...
Posted 22 February 2011 - 03:29 PM
Now, I used your file, and the file was the problem. First, to use a fixed-length file as yours is, you have to reference a schema.ini file that has the schema in it and also references your data file. I changed your file to delimited and added a header:
ID,Name,InDate,OutDate 15,John Brown,1/1/2011,2/1/2011 14A,Jesse Fender,12/15/2008,1/31/2009 27,George Lightel,2/15/2011,
And was able to access it fine using ADO (Which you really oughtta learn...
Option Explicit Dim cn As Connection Dim rs As Recordset Private Sub Form_Load() Set cn = New Connection Set rs = New Recordset cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\temp;Extended Properties='text;HDR=Yes;FMT=Delimited';" rs.Open "select * from test.txt", cn End Suband that's all you got to do to get the equivalent of an ADO Data Control's Recordset property. So, trouble is with your text file and how you're setting it up. I still can't see how you're getting IDKey, for example, when the string IDKey is nowhere present in the file you attach.
#10
Re: Q re: Random Access Files, data-aware obj...
Posted 22 February 2011 - 04:21 PM
The reason i have the ID tag was so that the information packed could be referenced like coorrds on a map...
EX:
'The . is a spacer... normally a space ' ID.....WTR.............CHAIR.............HOST............HOSTPHN 1......John Doe........John Doe..........John Doe........555-555-1234 2......Jesse Fender....Jesse Fender......Jesse Fender....555-555-1234 188....Happy Woods.....Happy Woods.......Happy Woods.....555-555-4321
in the Type Declaration:
Private Type SupportInfo
ID As Integer
WTR1 As String * 16
Chair1 As String * 18
Host1 As String * 16
HSTPHN As String * 12
End Type
That way when the program opens and reads informantion in the code can pull pos 2 and chair and the chair would be Jesse Fender. it is basicly so that the program can deal with the positions with in the file.
As far as the ADODC i have set that aside for now as i have gotten the loop function work atm, i will move to that at a later date... I have set my focus on leaning about getting sorts to work and help me create index files...
That is another long story... figuring how to load arrays, send them to arrange based on properties (for me a-z sorting...and in the more advanced themename(a-z)Talk number(1-N) all in one big index fest...)
The fun thing about the sorting functions is no one can comment what they are doing the process so i am lost as far as what i need to do to get it to work... makes me want to cry.
any way thanks for the help with this, i will save it so that i have it to refer back to it... if you want to read my woes about sorts, there is a thread lower in the line that discusses a shell sort that i i got off the MSDN and there was little explination of what it was doing...
My Issue with Shell Sorts...
Thanks again...
Jesse Fender
#11
Re: Q re: Random Access Files, data-aware obj...
Posted 22 February 2011 - 06:22 PM
Dealing with positions in the file. You can do all that stuff, or you can use the Recordset's Fields collection. rs.Fields(1) would be WTR, rs.Fields(2) would be Chair.
Getting sorts to work. Of course, you could go to all the trouble you describe. Or you could use the code I shared with you to create an ADO recordset and set its Sort property to a valid SQL WHERE Clause. You could even take the sorted recordset and run through it, writing its records to a text file.
That is, if you wanted to go to the trouble of figuring out the 6 lines of code I shared with you. Of course, your solution is certainly going to teach you more about sorting algorithms and the like.
As for the ADODC, I'd set it aside forever, not for now.
#12
Re: Q re: Random Access Files, data-aware obj...
Posted 23 February 2011 - 12:37 AM
BobRodes, on 22 February 2011 - 05:22 PM, said:
Dealing with positions in the file. You can do all that stuff, or you can use the Recordset's Fields collection. rs.Fields(1) would be WTR, rs.Fields(2) would be Chair.
Getting sorts to work. Of course, you could go to all the trouble you describe. Or you could use the code I shared with you to create an ADO recordset and set its Sort property to a valid SQL WHERE Clause. You could even take the sorted recordset and run through it, writing its records to a text file.
That is, if you wanted to go to the trouble of figuring out the 6 lines of code I shared with you. Of course, your solution is certainly going to teach you more about sorting algorithms and the like.
As for the ADODC, I'd set it aside forever, not for now.
Well I hate to break it to you Bob, the code snippet is not working for me... lol it is telling me that i am either the file i am trying to open is not valid, OR that im not connected... Ill post me code see if you can see what i am doing incorrectly...
Private Sub Form_Load() Me.Caption = "Text Delimited DB Program" Set NewConn = New Connection Set RS = New Recordset NewConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\FDFDB.txt;Extended Properties='text;HDR=Yes;FMT=Delimited';" RS.Open "FDFDB.PwF", NewConn
the code for creating the initial file...
Private Sub BuildDB_Click(Index As Integer)
'creates the DB file and sets up the LastRecord Listing Then becomes disabled...
LastRecord = 0
FFile = FreeFile
If FSO.FileExists("FDFDB.txt") = False Then
Open "FDFDB.txt" For Output As #FFile
Print #FFile, "ID", "TerrNum", "PubName", "CODate", "CIDate"
Close #FFile
LastRecord = LastRecord + 1
Open "FDFDBLR.PwF" For Output As #FFile
Print #FFile, LastRecord
Close #FFile
BuildDB(1).Enabled = False
Else
End If
End Sub
And the code that is supposed to control the record selection... i think...
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case FristRec:
RS.MoveFirst
RS.NextRecordset
Case NextRec:
RS.MoveNext
Case PrevRec:
RS.MovePrevious
Case LastRec:
RS.MoveLast
Case AddRec:
RS.AddNew
Case EditRec:
RS.Update
Case DelRec:
RS.Delete
End Select
End Sub
general decs code
Private FSO As New FileSystemObject, NewConn As Connection, RS As Recordset Private Position As Long, LastRecord As Long, FFile As Integer Private X As Integer, Y As Long, I As Integer, J As Long
I think i am doing something wrong... it really shouldnt be hard.... The file is a comma delimited file... which i cant make due to the program not letting me, even when it was there it wouldnt let me make it...
Any ways... the sort thing is for searching through the fields, and recreating and indexing all the files as they got changes... to make life easier.
Jesse Fender
#13
Re: Q re: Random Access Files, data-aware obj...
Posted 24 February 2011 - 04:34 PM
Next, your select case syntax is all wrong. In VB, Index is the value of the Index property in your control array, and will be 0,1,2,3,4,5,6 and so on. Also, you don't use : at the end of each case statement in VB.
Suppose that you first get so you can move around easily, and then we will work on updating and deleting and the like. Step one is to be able to open a recordset and move around in it.
#14
Re: Q re: Random Access Files, data-aware obj...
Posted 25 February 2011 - 07:05 PM
BobRodes, on 24 February 2011 - 03:34 PM, said:
Next, your select case syntax is all wrong. In VB, Index is the value of the Index property in your control array, and will be 0,1,2,3,4,5,6 and so on. Also, you don't use : at the end of each case statement in VB.
Suppose that you first get so you can move around easily, and then we will work on updating and deleting and the like. Step one is to be able to open a recordset and move around in it.
well in time i want to just use one file that holds many fields and what not, To start however i am working with the basic system... if i get the program to index files and deal with all that... the adoconnection is something i will start back on when i get back home... the text file will be renamed as a *.db file, and that way it will distinguish the database file and index files and record files (record files are seq files with a list of "last Records" for each db file.) I will work with that a bit too...
As far as the :
i will remove them as soon as i can...
The value of the index is the value of the control array that has been decl in an enum so they should be ok... if not i will look into that again...
Exactly, the purpose of this is to learn more about handeling files and records... With out datacontrols provided by MS...
A question Bob, did you use write or print for the delimeted file... i tryied both, but only one really looked like teh example you put in the last reply before this one. write packed close but had the "", print added tabs and no commas or "" not really sure if it matters.
Thanks for your replies...
Jesse Fender
#15
Re: Q re: Random Access Files, data-aware obj...
Posted 25 February 2011 - 07:40 PM
As for what I used for the delimited file, well, I used my favorite text editor and put the commas in by hand.
|
|

New Topic/Question
Reply



MultiQuote



|