|
Simon_Whale,
Thanks for your answer. I read the article posted in your link. I get the answer after I have read the first paragraph of the third 'floor' of answer. The rest (fourth floor to the 7th floor) of article does not help me that much. (Actually I don't really understand those answers. )
Anyway, I just call RemoveHandler before calling AddHandler with the same set of parameters.
|
|
|
|
|
Visual Basic is a very forgiving and accommodating language. In keeping with the VB6 legacy, it does a lot of plumbing for you behind the scenes without ever writing a single line of code. You don't need to check if an event handler exists before calling RemoveHandler, just call it.
|
|
|
|
|
Hi
Can anybody help me in defining how to control the number of users logged in to the application. I have tried writing to registry of the server but it seems that is not a very good idea since then lots of security related concerns arise.
I have checked Google but not found any good method. I know there are many ways which can be used but I need a method by which it can be kept hidden from the user/ client administrator and also will not be removed once the software is uninstalled for future reference.
Because of the connection problem in MySql, which happens to be the back-end, I would like to have a method which I can bind into my application.
Any help in this matter will be highly appreciated.
|
|
|
|
|
To answer that, you'll have to define "logged in user".
Assuming your users are listed in the database; add a table that references the users, and which adds a timestamp. Add a record when a user logs in. This is the "login-time". You could add a second, which gets updated with every action (over a trigger), called "last activity".
Problem; users do not always log out as required. Computers die, networks die, hence, connections die without notifying that the user is no longer active. Solution; consider every user active with a login-time that's not older than "today", and a last-activity not older than an hour or two. Require the inactive users to log in again, and you're there.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks Eddy. I think this should be fine. The only problem is the second part of my query where-in I would like to keep a track of future installations. I would like to keep a track on whether this application is installable or not.
Anyway as a first step this is good enough. In case you have any other idea do please share.
Thanks again.
|
|
|
|
|
SPSandy wrote: The only problem is the second part of my query where-in I would like to keep a track of future installations. I would like to keep a track on whether this application is installable or not.
The difficulty there is predicting future requirements; you don't know what the requirements of the utility (or it's dependencies) are.
Usually any updates on an application adhere to the requirements of the original application. That way one can install updates without performing a full system-check each time and without worrying about permissions. Anything that breaks the requirements is minimal a new release. Based on the logic that the old code cannot state claims over the new code (without outside help, like a webservice), it is the new code that provides the requirements-test.
The old code code be invoking something in the new code to ask whether it still complies with the old rules; sounds elegant, but given that it's the new code making the assessment anyway, it's more logical to have the installer for the current release perform the check, and the required updates. Typically run with admin-privileges, this mode enables you to take custom actions needed to meet any change in requirements, like downloading and installing extra required components, or beg the admin for a new harddisk
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy, Thanks for the explanation. I was actually referring to installations which can happen where they are not supposed to happen. For example If I install a trial version somewhere, I don't want the trial version to work again after un-installing and installing it again once the trial period is over. How do I stop this?
In this case I am not sure how the new version can check whether the installation is valid or not? This is where I am getting stuck. Not finding any logic to follow for this case. This is the reason why I thought of writing into the registry, but huge security concerns drove me away from that idea. The other idea was to create a text file and keep it in a highly populated area like Windows or anything of that sort. Again Security issues. Windows normally don't allow to write anything in its library.
This prompted me to come out to this forum and look for possibilities. But your idea of keeping a track of users through table is of course an area which I will take up.
Thanks again for replying.
|
|
|
|
|
SPSandy wrote: For example If I install a trial version somewhere, I don't want the trial version to work again after un-installing and installing it again once the trial period is over. How do I stop this?
Let's suppose I downloaded your software, and I done something stupid, had to reinstall Windows. Why prevent me from installing again? There's an alternative to stop people from indefinitely using your trial-software;
A trial-version does not need to include all features for test-driving your software. That's the best anti-piracy method I encountered. Visual Studio Express is downloadable for free, but the package is a lot smaller than the Pro-version. A feature that ain't there, can't be hacked. That's why some public-domain apps don't provide save-functionality for example; one can still test everything, but you'd have to buy the complete version if you want it all.
Anything on the local filesystem can be hacked, given enough time. Usually, it's not "worth" the time, and you clone the Virtual Machine. If you want more security, you'd use a web-server and ask it whether the user with given name has a (valid) license. It's a bit harder to circumvent that, but still, it might be possible to copy the answers of your server and later feed those copies to the client. If you want more security still, you need a hardware-token.
The additional advantage of not crippling the trial-version, but to offer an "express" version, is that you can start to encourage the sharing - and gain market-share. As soon as any of the express-users needs a pro-function, they'll convert.
The Pro-version could have the name of the client hardcoded in the source-code; if your webserver supports ASP.NET, you could inject the name of the client into a source-file once the download is requested, use the compiler to build it, and provide a custom download-location for their version. It's easily changed with the right tools, but it does discourage "sharing" the product a bit.
As you can see, no perfect strategy, and all with a cost. Invest your time wise
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
You need to handle it in Global.asax file. If you observe, this class inherits HttpApplication which has a property HttpApplicationState . So you can set a variable LoggedInUsers in ApplicationSate when the application starts (Application_Start method) and you can keep updating the variable in Session_Start & Session_End methods.
void Application_Start(object sender, EventArgs e)
{
Application["LoggedInUsers"] = 0;
}
void Session_Start(object sender, EventArgs e)
{
Application.Lock();
Application["LoggedInUsers"] = (int)Application["LoggedInUsers"] + 1;
Application.UnLock();
}
void Session_End(object sender, EventArgs e)
{
Application.Lock();
Application["LoggedInUsers"] = (int)Application["LoggedInUsers"] - 1;
Application.UnLock();
}
|
|
|
|
|
Thanks for the reply Pramod. But unfortunately I am totally ignorant in C# or C whichever this is written in. So I neither understand what this does nor on how I can use this in my application. I am writing my application in VB.Net
But I do appreciate your taking time and providing the details.
|
|
|
|
|
If you are using vb.net, no problem at all. Copy these methods one by one any try converting them to Vb.net online.
http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]
If you have the confusion of placing this code, then search for Global.asax file in your web project.
If it is not there then add this file to your web project.
Right click on your web project. Select Add->NewItem, then select Global.asax template from the template library.
|
|
|
|
|
Thanks Pramod for your reply. I will surely look into this.
|
|
|
|
|
Hi all,
for my app I retrieve 'SOAP' data (using the PayPal Api), which have to be written to an Excel file in the end. I don't have any experience with web applications, XML, serialization etc., so that I'm afraid the idea of assigning each field to the properties of a 'Transaction' class might be useless or at least a long way round.
From my logfile I can see that it's transferred in the format
<Status xsi:type="xs:string">Completed</Status><GrossAmount xsi:type="cc:BasicAmountType" currencyID="EUR">41.80</GrossAmount> and I try to fill the class this way ((...).= abbreviated):
For Each transactionDetail As GetTransactionDetailsResponseType In detailsList
If transactionDetail(...).LastName IsNot Nothing Then
Dim t2 As New Transaction
With t2
.Transaction_ID = transactionDetail(...).TransactionID
.Street1 = transactionDetail(...).Street1
.Quantity = Val(transactionDetail(...).Quantity)
End With
End If
Next From some web sources – which all seem to be written for experts – I assume there must me much easier (and less error-prone) ways to process the data, but I don't know where to start or find code examples.
Would someone be so kind as to give me some guidance?
Thank you very much,
Mick
|
|
|
|
|
Honestly, AFAIK, there is nothing that is much easier than this.
One could use reflection to read the properties of the proxy object and then assign them to similar properties in your model - but then you need to ensure the model property names match, and that does sound difficult.
Perhaps someone else can provide a better solution.
|
|
|
|
|
Thank you for the advice, anyway!
Abhinav S wrote: use reflection to read the properties of the proxy object and then assign them to similar properties I'd still give it a try, since I know all the names and datatypes so that I could rename my 'transaction' class' properties. But how would I code this? Could you probably give me a few lines of sample code?
|
|
|
|
|
Hi
I am having a problem with "Too Many Connections" in accessing MySQL from VB.Net.
The issue is I am loading huge amount of data from Excel to MySql using VB Grid. There is a check that if the data is already available then it will not be loaded based on certain key. If a lot of this Data is already available in the MySQl Table then even though I am closing the Connection using MySqlCommand.connection.Close() it still leaves a thread in the MySql resulting in a huge number of connections still open.
Can anybody help me in solving this issue?
Thanks in Advance
|
|
|
|
|
I had a similar problem with one of my programs and my solution was to open the connection at the beginning of the program, then re-use the connection each time I had to query the database.
The best performance is if you have a single SQLcommand and make use of SQLparameters so that you only change the value of the parameter for each different query.
Basically one connection, one sqlcmd, keep changing the value of the parameters.
See if that works for you.
|
|
|
|
|
Considering the cost of a connection license to some SQL Servers can be very expensive, and the fact that the connection would be completely idle for the vast majority of your applications lifetime, that is a horribly bad practice.
Standard "play nice and share with others" practice is to open the connection, execute your query, then close the connection as soon as possible. Do that and you won't hog the license preventing others from using it and pissing off the DBA's.
|
|
|
|
|
You are right Dave, But I think there is a little difference between SQL and MySQL. In SQL , I am not very conversant but I think, when you close a connection it actually closes the thread. But in MySql, as far as I have been working on it, I find that even if you close the connection it actually does not close it but stays in "SLEEP" mode and hence creates problems. BTW I am using the command MySQLCLIENT.Connection.Close() to close the connection. This command unfortunately leaves the connection as it is as seen using processlist. If I am using a wrong command or there is another command to close the connection, I would really like to know that.
Anyway thanks a lot for the input.
|
|
|
|
|
I don't use MySQL and so am not an expert on it. I just pointed out that the practice of holding open a connection for the life of an application is greatly frowned upon and should never be used in production code.
Fix the problem, don't work around it.
|
|
|
|
|
MySQLCLIENT.Connection.Close()
Try calling Dispose when you're done. Wrap 'em in a using block, and they get cleaned up correctly, without the need to call dispose explicit.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Maybe I should have been more clear. My applicaiton was a very short lived program which executed about a thousand queries. The whole program lasted less than 3 minutes.
It was kind of a crazy situation where I was processing data from one resultset (MS-SQL) and issuing queries to another server (AS400 DB2 via ODBC). I found that creating one connection, one SqlCommand and changing the value of the parameters gave me the best performance.
I agree that generally you don't want to hold onto a resource any longer than necessary, but in my case the overhead of opening and closing connections to the other server was more than I wanted.
Sorry I can't be more helpful with a mySQL specific answer. I'm just telling you what worked for me.
BTW: After re-reading the requirements of the original post, I believe my method of making one connection at the top of the application would be just fine. The author is loading data from Excel. Right? How long could this program take to run? A few minutes at worst. Having a single connection to the database for that period of time should be no problem.
|
|
|
|
|
Thanks David. It really did work.
|
|
|
|
|
You might want to look at this[^].
and if that doesn't work, go through these[^].
|
|
|
|
|
I need a Visual Basic code for a 25x25 sodoku game...please can anyone help me....
modified 23-Aug-12 21:58pm.
|
|
|
|