Re: [sqlite] [newbie/VB.Net + SQLite] Reliable file hashing?

2010-03-05 Thread Bernd Lehmkuhl
Am 05.03.2010 15:34, schrieb Gilles Ganault:

> In the following code, a record is added everytime, although this file
> is already in the SQLite database (I checked by opening it with a
> stand-alone application after running the program once):
>
> http://pastebin.ca/1823757
>
> The problem occurs around line 63.
>
> I'm using TEXT to hold the hash column: Could it be that, for some
> reason, this data isn't reliably saved or read, which would explain
> why a new record is INSERTed every time, even though this item is
> already in the database?
>
> Thank you for any hint.
>

Hi Gilles,

I think the problem is the query, whether there is already an entry in 
the database:

SQLcommand.CommandText = "SELECT id,name,hash FROM files WHERE hash='@hash'"

The parameter probably shouldn't be put in quotes as you did. This way 
the query looks for the literal '@hash' which doesn't get replaced by 
the SQLite-ADO.NET provider and which of course doesn't exist in the db.

Hope that helps, Bernd

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] [newbie/VB.Net + SQLite] Reliable file hashing?

2010-03-05 Thread Xevi
Hello,

I can't check the VB at this moment, but I think that you dont need de
single quotes around the @hash parameter in line 65.

Hope this helps
Xevi


Al 05/03/2010 15:48, En/na Nick Shaw ha escrit:
> Small aside: Why do you select the id, name AND hash in the select?  You
> don't appear to use them.
>
> I can't see anything specifically wrong, but try doing "SELECT COUNT(id)
> WHERE hash='@hash'" instead, and see if the returned count > 0 or not.
>
> You could also maybe test your routine by passing in a fixed string as
> the hash='@hash' value each time and check it does actually returns
> rows.
>
> My guess is there's something subtle wrong with the VB.NET code, but my
> VB.NET syntax knowledge is not up to the job of finding any problem I
> can see. :)
>
> Thanks,
> Nick.
>
> -Original Message-
> From: sqlite-users-boun...@sqlite.org
> [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Gilles Ganault
> Sent: 05 March 2010 14:35
> To: sqlite-users@sqlite.org
> Subject: [sqlite] [newbie/VB.Net + SQLite] Reliable file hashing?
>
> Hello,
>
>   I'm having the following issue while looping through a
> directory:
> for each file, I need to hash its content, check if this file is
> already in an DB, add a record if it isn't.
> The goal of this application is to check a whole drive for UltraEdit
> temp files, check for duplicates, and save any unique file into a
> backup directory.
>
> In the following code, a record is added everytime, although this file
> is already in the SQLite database (I checked by opening it with a
> stand-alone application after running the program once):
>
> http://pastebin.ca/1823757
>
> The problem occurs around line 63.
>
> I'm using TEXT to hold the hash column: Could it be that, for some
> reason, this data isn't reliably saved or read, which would explain
> why a new record is INSERTed every time, even though this item is
> already in the database?
>
> Thank you for any hint.
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>   
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] [newbie/VB.Net + SQLite] Reliable file hashing?

2010-03-05 Thread Nick Shaw
Small aside: Why do you select the id, name AND hash in the select?  You
don't appear to use them.

I can't see anything specifically wrong, but try doing "SELECT COUNT(id)
WHERE hash='@hash'" instead, and see if the returned count > 0 or not.

You could also maybe test your routine by passing in a fixed string as
the hash='@hash' value each time and check it does actually returns
rows.

My guess is there's something subtle wrong with the VB.NET code, but my
VB.NET syntax knowledge is not up to the job of finding any problem I
can see. :)

Thanks,
Nick.

-Original Message-
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Gilles Ganault
Sent: 05 March 2010 14:35
To: sqlite-users@sqlite.org
Subject: [sqlite] [newbie/VB.Net + SQLite] Reliable file hashing?

Hello,

I'm having the following issue while looping through a
directory:
for each file, I need to hash its content, check if this file is
already in an DB, add a record if it isn't.
The goal of this application is to check a whole drive for UltraEdit
temp files, check for duplicates, and save any unique file into a
backup directory.

In the following code, a record is added everytime, although this file
is already in the SQLite database (I checked by opening it with a
stand-alone application after running the program once):

http://pastebin.ca/1823757

The problem occurs around line 63.

I'm using TEXT to hold the hash column: Could it be that, for some
reason, this data isn't reliably saved or read, which would explain
why a new record is INSERTed every time, even though this item is
already in the database?

Thank you for any hint.

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] [newbie/VB.Net + SQLite] Reliable file hashing?

2010-03-05 Thread Gilles Ganault
Hello,

I'm having the following issue while looping through a directory:
for each file, I need to hash its content, check if this file is
already in an DB, add a record if it isn't.
The goal of this application is to check a whole drive for UltraEdit
temp files, check for duplicates, and save any unique file into a
backup directory.

In the following code, a record is added everytime, although this file
is already in the SQLite database (I checked by opening it with a
stand-alone application after running the program once):

http://pastebin.ca/1823757

The problem occurs around line 63.

I'm using TEXT to hold the hash column: Could it be that, for some
reason, this data isn't reliably saved or read, which would explain
why a new record is INSERTed every time, even though this item is
already in the database?

Thank you for any hint.

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users