PDA

View Full Version : I Really Really Really Need Help With Sqlite


daffy
03-27-2007, 02:25 AM
I guess my first post was either TOO HARD for the brains to figure out.......or TOO SIMPLE. hAVEN'T MADE UP MY MIND WHICH.

i'M SORRY BOUT THE ATTITUDE.......I hate being ignored. At least one of you moderators could at least tell me I'm stupid and NO ONE has the brains to help me.......then I'd feel better.......still stupid........but better hahahahahaha.

YOU guys are great, really.......and SORRY (really) for "venting" please forgive me.

so once again, I'll submit my "stupid" problem hahahaha. :lol :lol :lol

AS FOLLOWS:

Not sure if this is where I should be asking this......but here it is.:huh :huh :huh :huh :huh

I need to take an .ini file, and check it's values again a table in database.

Example: Ini file

[FIELD1] -- this will be a File Name
FIELD2 (sub name) = (crc value) -- the rest will be values stored
FIELD3 = 0
FIELD4 = (crc value)
FIELD5 = (crc value)
FIELD6 = 0
etc.............
(FIELD2 onward are the fields in the DB this will be a constant)
exmpl DB tbl: ini_name,one,two,three,four,five,six.......

What I need to do with the DB is:

FIRST:
I need to check if the "FIELD1" name already exists.
and if it does, check all the values in the INI (section name and values) against it to be sure the INI "MATCHES" the data for "FIELD1" first then check the rest of the values in the DB to be sure it is an exact match.

SECOND:
If the "Section Name" of the INI DOES NOT MATCH Field1 of the DB table, I want to check the "values" (INI), against Fields2 onward (DB) to see if the "data" matches. (just in case the recipient named HIS file another name (section name) of INI, but has the same values.
(if no match for file name, but all data matches, then a dialog saying same giving choice to "rename" their file in the DB.


If "Section Name" (INI) and FIELD1 (DB) value matches but the "data" in FIELD2 onward do not match, then i want to do a dialog to inform them of same and stop the search.

if everything matches, then I "do" something.

if nothing matches then a dialog ACCEPTING the new file name and values into the DB.

RizlaUK
03-27-2007, 08:59 AM
dude, im sure that your post wasent ignored, overlooked maybe but posts never get ignored

also i dont think venting then saying sorry and asking for help is the best way to go about getting it

however, i have done something like this on one of my projects (compair ini values to a database) but im not at my pc right now, when i get home ill dig out the code and see if i can make you a example (if on one else can help in the mean time that is)

in fact, im sure there is a example on the forum somewhere, as i seem to remember getting my code frame from a example here on the forum


just a thought, you might be better off (as it will be easier) to store the values in a text file and read it to a table, then compare the table to the database table

TJ_Tigger
03-27-2007, 09:21 AM
Could be that people are busy with spring break, at least here in the US. I missed your post as I was not online for most of a week since I was on holiday with the kids.

Anyway, if you feel your post does not get attention then just post to your original post and bring it back to the top.

Also what code have you tried? Have you been trying to get it to work?

Here is what I would do.

First I would make sure that the valuenames within the sections match the fields(columns) in the database. Doing this will help make the comparison of individual fields much easier. Also the section names would also correlate to a field in the database and maybe you want to name that column "sectionnames" or some similar title. Once you have this formatting down then you can move on to the actual comparison.

Here is how I would start the comparison. Get all section names from the ini file. This will return a table that we can use to then step through each entry and compare it with the database. Now that this is in a table you can use a for loop to step through the table and take the first item and formulate a query to look for that section in the table.

Here is a sample of what the code might look like

tbINISN = INIFile.GetSectionNames("filename")
if tbINISN then
for i,v in tbINISN do
tbReturn = SQLite.QueryToTable(db, "Select * from table where sectionname = '"..v.."')
if tbReturn and tbReturn.Rows > 0 then
--the item exists then you can compare the fields
--if the valuenames in the ini are the same as the column names in the db
--then you should be able to loop through each and do a comparison.
else
--take other action here to enter that information into the database
end
end
end

Code like the above would loop through all the sections and compare all the fields.

I hope that helps to get you started.

daffy
03-31-2007, 10:33 PM
To Tigg and those that responded to me......after this Jackass (me) tried to get their attention to what I thought was indifference hahahahaha. It's was the "impatience" of this dumb jackass. SORRY.

Anyways: TIGG.........or anyone else who can wee what i'm TRYING to do with this......it's for more or less a clan database.

AS FOLLOWS;;;;;;;;;



-- DB TABLE EXAMPLE

(field)Preset (field)Model_Type (field)gign (field)gsg9 (field)sas
Test One 1 gign 10 gsg9 2 sas 11
--- INCLUDES MORE FIELDS AND HAS EITHER A NAME OR IS "EMPTY"



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%

Tigg... I understand what you're trying to tell me, but I can't "see" it in my head and translate it to code.


What I'm trying to do is
FIRST: EXCLUDE "Preset" and "Model_Type" (in BELOW INI) and just check if the "SectionNames" and "ValueNames" (not worried bout the
"Values" yet) are a MATCH in ONE row of the ABOVE DB .


SECOND: I want to check if the "Preset" values in INI and DB MATCH or DON'T MATCH.
If ALL THE VALUES MATCH (except for "Preset Name" and "Model Type") the DB values, but the "PRESET" value does not match then I do a dialog saying "partly matches" for example.
And give them a choice of several options.

OR

IF ALL VALUES MATCH, again...it's a "duplicate" and doesn't need to be entered in the DB.

OR

IF ALL VALUES DON'T MATCH....... accept the NEW record into the DB

*** WHAT I'M TRYING TO DO, I just can't see where I'm going WRONG***

FilePath1 = _ProgramFilesFolder.."\\CSAPC\\Incoming\\Temp Processing\\"..sVersion.."\\New Clan Files\\New Folder\\Test One.ini"
tbINISN = INIFile.GetSectionNames(FilePath1)
if tbINISN then
for i,v in tbINISN do
if v ~= "Preset" then
if v~= "Model_Type" then
tbVALNAMES = INIFile.GetValueNames(FilePath1, v);
for i,x in tbVALNAMES do
tbReturn = SQLite.QueryToTable (db, "SELECT * FROM preload WHERE ('"..x.."' = '"..x.."')")
if tbReturn and tbReturn.Rows > 0 then


AM I CLOSE??????? HAHA

else
--take other action here to enter that information into the db
end
end
end
end
end
end

************************************************** ************************************************** **



I can't see it.........I know it's there....but my "jackass" brains isn't seeing it.....and it's probably "easy
to see" hahaha.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%
--INI EXAMPLE

[Preset]
Preset Name=Test One -- Preset Name
[Model_Type]
WpnsPlyrsboth=1 -- value of 1,2 or 3


[gign]
gign 10=1946830420 -- Archive Name = crc (obtained from another tb)
[gsg9]
gsg9 2=4258430488
[sas]
sas 11=1155274053
[urban]
urban Eva 00=3297491310
[vip]
= -- If the corresponding field in the DB is empty,
then ValueName and Value will be nil
[hostage]
=
[scientist]
=
[arctic]
=
[guerilla]
=
[leet]
=
[terror]
=
[deagle]
=
[fiveseven]
=
[elite]
=
[glock18]
=
[p228]
=
[usp]
=
[ak47]
=
[awp]
=
[aug]
=
[scout]
=
[m4a1]
=
[g3sg1]
=
[sg550]
=
[sg552]
=
[mac10]
=
[mp5]
=
[p90]
=
[tmp]
=
[ump]
=
[c4]
=
[flashbang]
=
[hegrenade]
=
[smokegrenade]
=
[knife]
=
[m249]
=
[xm1014]
=
[m3]
=