Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to run a vb.net program from SQL Server 2005?

Author  Topic 

Antinsh
Starting Member

16 Posts

Posted - 2008-03-15 : 10:59:17
Hi. First 3 paragraphs are about problem in general - this is for those who consider them well experienced and may have better ideas about how to solve this whole thing. In forth paragraph is the tehnical question.



Hi. First 3 paragraphs are about problem in general - this is for those who consider them well experienced and may have better ideas about how to solve this whole thing. In forth paragraph is the tehnical question.

Situation:
So me was trying to find out why files are saved in database incorrectly. First idea was to create a MD5 checksum of a file in my application and then create one with SQL script that saves data in database (data being the file, by the way).

On software side it worked fine 'cuz i'm developing in Visual Basic .NET 2005 which has a function that return a 32 byte array of hash from a data that you pass to it (like file) - GREAT!

SQL Server 2005 side - not so great. The only function that I have found so far that creates hash is HashBytes that is supposed to do it's job only there's a limintation to data size which means i cant make hash of say 4mb big file.

Problem:
So I figure maybe i could create a vb.net program that return a hash from a data passed to it and call it with SQL script (because hashbytes function doesnt work for me in case you didnt read the first 3 paragraphs)... but I don't know how:(
Any ideas?

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-03-15 : 11:04:52
Why not just write a vb.net program to do this?

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

Antinsh
Starting Member

16 Posts

Posted - 2008-03-16 : 01:16:15
I cant use a program because this software is kinda already finished.
And some parts cannot be changed - one of them being the way data is sent to database which is something like:

1)Create a command in vb
2)Pass arguments to a command (this is where I also pass the hash bytes)
3)Give the name of stored procedure
4)Execute query
... so this structure is not about to change. That taken in mind I see no other way (maybe someone else does?) to check wether file was sent correctly than to find a way to call a function from Stored Procedure that would create a new Hash that I could compare to the one that came from application.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-03-16 : 08:53:56
Ok, I've got that part down -- now, how will your proposed function/stored procedure work? When does it get called? Who calls it? Write out the workflow for how you'd like your validation process to run, and then we can figure out the best way to do it.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

Antinsh
Starting Member

16 Posts

Posted - 2008-03-18 : 14:03:37
Hi!

To begin with It seems (at least from your reply) that you know this whole thing not only from parctical but from theretical standpoint... unlike me - i had pretty dumb programming teacher but anyway:)

You asked about "workflow for how you'd like your validation process to run". Going back to those steps whole magic is supposed to happen in 4th step (execution of query) which basicly is
1) create checksum from data (in query)
2) check if the checksum matches the one that is sent to query
3) if they match update data in db and set the output variable bitSuccess=1
4) if they dont match set the output variable bitSuccess=0

...and when it is completed application check if bitSuccess=1 and if not do the whole thing again (send data, execute query)
The only thing that i dont have now is the 1. part of query (checksum creation)
Actually someone kinda gave me code for that part but I have some problems with maybe you can solve it. Here's the forum thread:

http://forums.microsoft.com/forums/ShowPost.aspx?PostID=3016940&SiteID=1

Sorry that I didnt answer sooner. It's just that this isnt the only thing I'm working with at the moment.
Go to Top of Page
   

- Advertisement -