
Varghjärta
Avatar/Signature-
Posts
27 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Varghjärta
-
[SQL][SQlite] Pattern matching with subquery
Varghjärta replied to Varghjärta's topic in Database / XML / Reporting
Maybe you are right. But then again, the whole point of me using subselects is to kind of do a query that is automatically used in another query (all in _one_ query), so that I won't have to _manually_ via coding (whatever programming language) actually do one query and then another one and insert the previous result (somehow it feels more dirty and hack'ish). I'm afraid I don't have any code since there is none, i'm doing all of this directly against the database so to test if it is even possible before I embark on designing the actual application -- I tend to do this, experiment and see what can be done if it is a territory I'm not _very_ comfortable in. So as to avoid future problems. This is driving me crazy since it _should_ all be so easy, I want to associate rows in a table with rows in another table. The thing is, I will have two tables (for example): _______________________________________ ## items #id(int) | path(string) | tags(string) 0|"item1"|"o,2," 1|"item2"|"1,2," ## tags #id(int) | name(string) 0|tag1 1|tag2 2|AnotherTag _______________________________________ In this example I wanted to associate tag1 with item1, and tag2 with item2. And "AnotherTag" with both all of the items. What I will get from user input (via a GUI), is the name of the tag(string). So if I want to fetch all items associated with the tag "AnotherTag", it would be sweet if I could make the query work having only knowledge of the Tag name, and not already knowing it's _actual inner id_. Is this overkill, and is there an easier more elegant way of making association in this fashion?. I imagine the most _elegant_ approach would be to have a third table where I would store all the associations. BUT, it feels as though that could add to the complexity and it would be nice if I could make due with as little fuss as possible, namley somehow using The already existing and fast pattern matching ('%' for instance) to match against the content in the "tags" field of the items. Thank you! P.S. The more elegant approach of a third table would increse the size of the db too. There will be well over (minimum) of 300 000 items. The size of the db(my test-server so to speak) is at present about 20Mb. Having double that or tripple the amount of rows in a third table due to each tag association with each item, feels as if it might become something overwhelming, and not necessary if using SubSelects the way I want to would work :( . -
[SQL][SQlite] Pattern matching with subquery
Varghjärta posted a topic in Database / XML / Reporting
Hey, I'm having problems using LIKE when using a SELECT within the main SELECT. items.tags might contains something to the effect of "1,2,3,". The subquery returns one result in form of id which will be a number. To make my main select work I would idealy insert a wildcard before and after the injection from subquery so that the actual injection beomes "%1,%". Would make things real easy. But I can't get it working. How would I form such a query so that it actually works lol ? Any help appreciated, having googled for an hour i'm no smarter. Thanks. # Psuedo code SELECT items.path FROM items WHERE items.tags LIKE "%" + (SELECT tags.id FROM tags WHERE tags.name='one') + ",%" -
Thank you! :) This application thing I need is ment for a friend, yes truly; a friend. Whom I just now got to install .net 2 runtime. The problem I forsee at the moment though might be that it is not enabled in her XP. And she is using XP Home and appearently MS have hidden alot of things. Not even running: "%SystemRoot%\system32\secpol.msc /s" directly works. Any programatic way of enabling it? Thanks in advance!
-
Hi!. Does anyone know how one would go about monitoring or fetching info in some system log about login attempts that has failed. The application would be running, where upon the user would "lock" Windows. And I need to be able to keep track of login attempts. For instance if someone were to try and log on to my computer i'd later be able to see the time and such for the event. Is this possible somehow? EDIT: On Windows XP systems.
-
Well, I stole the php blowfish from: http://pear.php.net/package/Crypt_Blowfish And in c# I used "XCrypt" from : http://www.codeproject.com/csharp/XCrypt.asp Now, it has come to my attention that it's no guarantee that different implementations of blowfish will be cross-compatible. But then, I need to find one that _is_ for php+c# *sigh This kind of feels impossible, now if only I had c# support on my webhost I could have used the same dll.
-
Hey peeps! Alright my problem is as follows, for whatever reason I may have (a clever one trust me :) ) I _need_ to be able to open up binary files(or text, but binary should be faster so i'm going with that) containing encrypted text in Unicode. My problem is more specifically that in my recent try runs I've been unable to encrypt a file from C# and then via PHP decrypt it. The stuff I get back from php is just mumbojumbo (same key has been used). I've attempted this with the Blowfish algorithm, one that I found to .net and one which I found to PHP. NOW, correct me if i'm wrong but shouldn't the 'same' algorithm be able to open whatever data made by any software as long as it's _that_ algorithm.. is not Blowfish == Blowfish?? Any ideas? I would also appreaciate any pointers to other algorithms that _should_ work and exists to both c# and php, but I'd prefer to use the ones I have counted on for many years. Which is mainly Blowfish, Twofish & Rijndael (in that order) and I count them as very strong and safe. Thanks in advance!
-
This is a large concern for me as well, and have made me gone over to c++ many a times. But for all you are rewarded using .net (the ease of development etc etc) comes with that price, that you gotta have the .net runtime installed to use the application. There's no way around that I know of. One can only hope that Windows will ship with the runtime preinstalled in the near future so that soon everyone will have it, which I think is MS's idea. But until that time you gotta get it some other way. I'm not sure about the possibility to embed the runtime with ones program but do you really want your application to be 23+mb? But perhaps somehow it's possible to embed only those libraries one uses and thus lessen the size needed. Pehaps... I doubt it though!. But I wish it was possible as I seldom use very many "system.*" classes as I make my own collections etc etc to suite the application in question.
-
Sounds like what I wanted to for an application long time ago. I could never find any ready made code for it (though there probably is something, dealing with formating in some class). Can't you do a loop that inserts a comma into the string at appropiorate places WHILE we're not at the end of the string. And it might be easier code-wise to reverse the string before doing it so one loops form beginning to end so that the commas ends up in the right places(so we don't need to know anything about the number to still insert into the right place), then reverse it again so it's back to normal. Well atleast that's what you could do if you want to have them in groups of three(say: "1284"->"1,284", "1284999"->"1,284,999" etc). If that's something you need lemme know and I'll try to find the code snippet of mine.
-
Umm.. You mean right click on the icon in systray and be presented with a context menu?.. Simply assosiate a context menu with the tray thingy whatever it's called, then that menu will show with right clicking in the tray.
-
Sure. If it was just the encryption part your asking about: http://www.codeproject.com/csharp/XCrypt.asp And download the sample/source. But perhaps you were asking about the encryption of data in your specific situation. But then again, I can't think of a reason why it would differ. Encrypting traffic that would be sent over a network/internet simply entails putting a wee bit of encryption on the transmitting end just before the data is sent and decryption in the reciving end decrypting the data before the data is delt with as usual(by the application, whatever it is supposed to do). No changes should really be needed other than adding that little layer. I might be missing something though, but I can't think of what in that case.
-
Depends on what kind of data yer sending and how paranoid you are ;).. I would encrypt it... but then again, I encrypt everything. I implement encryption into my applications weather or not it's necessary or not. Those black vans outside my house won't get my recipes for apple pie no siree bob!
-
Referring to a control from a string variable
Varghjärta replied to Spektre's topic in Windows Forms
Have you solved the problem yet btw?.. -- been a while since I've been here. PS.. Why don't you just create your _own_ version of a control-array or whatever it's called. Make a class with a hashtable in it to wrap and hold references to all controls of a partiqular type. Make methods to edit the controls like setText("MyTxtBox","new text") and have it change the text in the textbox that is references/stored in the hashtable -- via key of textbox's name. Hashtable's are insanly fast, and if you for each textboxadded to the control add it to the hashtable -- by means of listening for added controls, start listening _before_ all the textboxes is added -- you won't even have to manually add them.. which if I'm not incorrect was the whole point?.. since your gonna have so many of them.. That's what I think i'd do..... if you have already cracked it then feel free to ignore this :). -
I only speak C# unfortunatly :). But what I guess you need to do is provide a way of hosting a control in a SubItem. I've nver done such personally, but I know there's articles on the subject over at CodeProject(.com), I know there's C# code there atleast. But if you need it badly perhaps you could try and port it. Or use the control as a dll and load it into your VB project. I myself will be needing somethign simular in the near future, but I want a progressbar, and my first stop will be to search over there for clever ideas.
-
Referring to a control from a string variable
Varghjärta replied to Spektre's topic in Windows Forms
You could listen for every control added to the form and then add it's reference to a hashtable. Then simply ((TextBox)hashTable["textbox1"]).Text = "bla bla bla"; Computers are pretty fast, I can't belive there should be an een noticible performance hit even if you had over 1000 textboxes. And Hashtable itself is _extremly_ fast. -
Referring to a control from a string variable
Varghjärta replied to Spektre's topic in Windows Forms
-
Referring to a control from a string variable
Varghjärta replied to Spektre's topic in Windows Forms
If I understand you correctly, you have to first get your hands on a reference to that textbox. The easiest way I'm guessing would be to (psuedo code): foreach(Control C in Controls) { If C.Name is what you want, using substring() or EndsWith() to check for that number Then cast the control to a textbox; TextBox MyBox = (TextBox)C; And now we can MyBox.Text = "Bla bla bla bla"; break; // break out of loop since we're done... } That should work. I didn't write much real code, becouse I only know C#. -
Referring to a control from a string variable
Varghjärta replied to Spektre's topic in Windows Forms
I'm not sure I understand you, do you wanna use the same event handler for i.e all those buttons. But have it only change the text of it's corresponding textbox? Well, not sure there's a better way but at the top of my head; have you considered looping all controls for textboxes and checking if it bares the right name or tag? -
nods* Reading/writing after every change is a very linear way of doing things. Kinda like one might be doing in a script that runs and dies very quickly. Takes a while to get used to the more long-lived nature of application-programming -- Speaking from my own point of view of coming to C#.
-
I myself have a soft spot for the StreamWriter and StreamReader, mainly becouse it allows me to write such great amount of data to a file very quickly and then read it also in half that time -- with the benifits of stream. This is, if i'm trying to store something in my own format, if your storing settings or some general stuff XML would probably be alot better. XML makes it all cleaner and more portable. So in general, I myself prefer to store settings in XML-files and then the masses of data my application uses in ordinary text-files with some formating/structure that suits the specific needs of that partiqular data. It's also the easiest and quickest to implement (reading a file to memory takes what, one or two rows of code.. and I'm lazy so that's good for me). _____ Well, I guess it all depends on what exactly you are gonna do. I mean what type of enviroment your code will be living in. Is it a real stand alone application or some web-thingy?. I only use .net(c#) for Applications and not Web (I prefer PHP for that). If your doing an application that will be running for a little while, say during multiple modifications of the data. The smartest and most efficiant way would be to load the data at start up. Put it somewhere (some class designed to hold each person or whatever stored in an arraylist,hashtable) in memory and then do your work against the data in the arraylist/hashtable. And _then_ when you want to save or close the app loop all data and output it to the/a file. The more data the slower it will become to save/load(pretty logical). I guess it might not be an issue if you won't have so much data but who knows how much you will store in a few months. ______________ If you absolutly want to operate directly on the data in a file for whatever reason, the only one I can think of is if it's a very shortlived app such as some web-thing, and perhaps the performance hit of loading and writing is something that one might notice. Then I guess your most efficiant course would be to store the data as usuall in some text file. And then we must know where the data is to be able to jump to it and write there directly (without loading everything to memory we can't know). So then you'd have to store some sort of index (possibly in another file) that states for example at what line number all the data is.. ____data.txt Worf Klingon ET Alien Alfred Human ____data_index.txt Worf:1 ET:4 Alfred:7 ___________________________ So if we read the index file and parse the data(split() comes to mind), and we want to change the race of ET, we know that his definition begins on line 4. And each person definition begins with name followed by race on next row. We know this since we are the one who saved the file in the first place and decided in what order things come. Then we can directly jump to the 5th line and replace it with something else. Of course, keeping an index of something like this comes with a performance penalty since we must read the index before we can do anything. So you will only benifit performance wise if the main data file contains such large amounts of data that the time it takes to read it all is greater then reading the index file. Becouse the index file will obviously also take a while to load if there are a few thousand "person definitions". In this example with only name and race the gain we have is.. almost nothing since it's so little data. But if you store much data per every "cluster" or "group" -- name & race being a group -- of data then you will gain by keeping that extra index and be able to jump directly somewhere and write. _______________ For stand alone applications I would greatly prefer just reading it all at start up. Easier and not as much code :P, i'm lazy. But if your doing web-stuff and you want that extra speed/performance the index-route is probably better. Now I must go eat something, been coding all day. I hope I've been of help.
-
Not sure I quite follow you but if you really have to modify a file I guess one way would be to keep a record of where specific data is (row number) stored in another files. So that you can write directly to a specific spot in the file. But wouldn't it be éasier to just read the entire file into memory at the exceuction of the app for instance. And then do all modifications in memory, then when you wish or at applications end write/replace the file with the data from memory? Writing many thousands or rows to a file takes only a fraction of a second(for me atleast), so unless your storing millions of rows rewriting the file from scratch seems like your best and quickest bet.
-
Perhaps you could post the code you try to use that doesn't work?? I used to use it very extensivly until I made my own for performance.
-
I've only ever seen a "Aqua button". But i've often found myself wanting much more.. and wanting to start on some control but I never get around to it. It would be sweet if there was any more somewhere that someone had already made. PS. Though by using an aqua-theme in XP all buttons etc gets the aqua look anyway.. so I guess most Aqua-lovers don't feel as though it's a big problem.
-
No problem, lol, yes it does seems as a strange way of doing it. I don't even really know C++. Perhaps you should consider emigrating to C#!? it's a lot cleaner,straight forward and logical, atleast from where i'm standing, I mean, if your gonna use .net anyway might as well go all the way :D PS.. didn't mean to sound too missionary.
-
Try this. OpenFileDialog* openFileDialog1 = new OpenFileDialog(); Bitmap* MyImage; if(openFileDialog1->ShowDialog() == DialogResult::OK) { MyImage = new Bitmap(openFileDialog1->FileName); pictureBox1->Image = dynamic_cast<Image*>(MyImage); }
-
It looks like your not storing the fetched image correctly. FromFile is static and you should store it in "face" instead then give face to the pic box. Image *face; openFileDialog1->ShowDialog(); face = Image->FromFile( openFileDialog1->FileName ); pictureBox1->Image = face; since I don't know that language I'm just guessing here. this is the C#.net equivelent which i'm positive would work. OpenFileDialog openFileDialog1 = new OpenFileDialog(); Image face; openFileDialog1.ShowDialog(); face = Image.FromFile( openFileDialog1.FileName ); pictureBox1.Image = face;