|
Thanks very much I knew there had to be a better way!
P.S. What's wrong with using one of the string constructors to create a string?
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
I dunno. But Jeffery Richter says not to. So you know what I don't do? Use the String constructor. In Applied Microsoft .NET Framework Programming, page 253, he says:
"In C#, you can't use the new operator to construct a String object..."
Go figure...
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
David Stone wrote:
"In C#, you can't use the new operator to construct a String object..."
The code I gave does work as it should do so, can't is a bit misleading; shouldn't may have some merits, though.
David Stone wrote:
Jeffery Richter says not to
If Jeffrey says so, then I will cease this instant. I keep meaning to get the book or something similar, but haven't quite got round to it yet. I'm too busy blundering about unguided
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
AHHH. Damn and blast. David beat me to it.
Yeah, hes right. Yours isn't the best way of doing it.
public string test2(string strBoxPassword)
{
byte[] bPassword = System.Text.Encoding.Default.GetBytes(strBoxPassword);
System.Security.Cryptography.SHA1 shaM = new System.Security.Cryptography.SHA1Managed();
byte[] hash = shaM.ComputeHash(bPassword);
return System.Text.Encoding.Default.GetString(hash);
}
Note that this and Davids reply are pretty similar except he excplicitly speficies the Unicode encoder. However, please note that both these methods WILL NOT return the same hash as your old method. The reason beeing is that you hard code 50 characters in the source byte array no matter what the actual length is. Our methods only hash the actual contents of the data and no extra trailing bytes.
Therefore if you already have hashes in your DB based on the originial code your probably going to have to either stick with what you have or re generate all the hashes...
Pete
Insert Sig. Here!
|
|
|
|
|
Pete Bassett wrote:
AHHH. Damn and blast. David beat me to it.
It helps if you were working on the same bit of code for a personal project just about a week ago.
Pete Bassett wrote:
Note that this and Davids reply are pretty similar except he excplicitly speficies the Unicode encoder
Death to ASCII! Long Live Unicode! Actually, your method might take Unicode...I'm not sure...
[edit]Actually, your method gets the System's current encoding. So if your OS was based on Unicode(XP I think) then it'll get a Unicode encoder.[/edit]
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
David Stone wrote:
So if your OS was based on Unicode(XP I think) then it'll get a Unicode encoder
Wrong! Default encoder with actually return the current windows codepage. Dont ask me how, but I realised that working on my irc client. Very strange indeed. Best is just to use the same Encoder/Decoder, and not rely on different (but perhaps similar) ones.
"I dont have a life, I have a program."
|
|
|
|
|
Hope you don't mind my asking...but what the heck is a codepage?
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
David Stone wrote:
but what the heck is a codepage?
Not really sure either, but I think it is an extension to ASCII based on your system culture. Something along that path....
"I dont have a life, I have a program."
|
|
|
|
|
Found it!
http://www.microsoft.com/typography/unicode/cscp.htm[^]
In Windows 95 and NT, a codepage is a list of selected character codes in a certain order. Codepages are usually defined to support specific languages or groups of languages which share common writing systems. For example, codepage 1253 provides character codes required in the Greek writing system.
The order of the character codes in a codepage allows the system to provide the appropriate character code to an application when a user presses a key on the keyboard. When a new codepage is loaded, different character codes are provided to the application.
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
Thanks very much I knew there had to be a better way!
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
I have my inherited form created and I have the controls set to be modifiable, setting them from Private to Protected. I also added the Main() logic so that all inherited forms can be selected as a starting form.
1) The documentation says I can compile to either a DLL or an EXE, I create a DLL and create reference to that DLL, yet when I create a new inherited form, it complains that the EXE does not exist. Do I have to create BOTH an EXE and DLL????
2) All of the stuff I've read indicates that I can create code in my base form and that code will be inherited in each instance. However when I create a new inherited form, it does not copy my [STAThread] code! I have yet to try creating control code, but I expect that that code would not copy either.
Any help on smoothing out these last two bumps is appreciated!!!
Thanks.
_____________________________________________
I have a tendancy to where my mind on my sleeve I have a habit of losing my shirt...
|
|
|
|
|
Anybody know how to go about getting a handle to the default windows cursor?
Cursors.Arrow.Handle returns what seems to be a valid handle, but I get an error when I call
InPtr Hicon = Cursors.Arrow.Handle;<br />
<br />
Bitmap tempBitmap = Bitmap.FromHicon(Hicon);
The error is "invalid parameter used"
\\winnt\cursors doesn't seem to contain the actual default arrow cursor as a ".cur" file. It's defined in winuser.h via MAKEINTRESOURCE(...) with the identifier IDC_ARROW.
I wouldn't mind going the unmanaged route. (I'm doing this in fact, but using a cursor in the \\winnt\cursors directory). But that's just a temp solution as I really want the default cursor. How would I define Win32's LoadImage(...) or indeed the LoadCursor(...) function with regards to the MAKEINTRESOURCE(...) call?
Gosh, what an ugly question eh?
ASP.NET can never fail as working with it is like fitting bras to supermodels - it's one pleasure after the next - David Wulff
|
|
|
|
|
Senkwe Chanda wrote:
InPtr Hicon = Cursors.Arrow.Handle;
This IntPtr is actually a WIN32 HCURSOR, not a WIN32 HICON, hence the error.
Back to real work : D-19.
|
|
|
|
|
Thanks .S.Rod. I'm used to using them interchangably via win32. Do you have any ideas on how I can get access to the handle for the default windows cursor? IDC_ARROW?
ASP.NET can never fail as working with it is like fitting bras to supermodels - it's one pleasure after the next - David Wulff
|
|
|
|
|
Senkwe Chanda wrote:
Do you have any ideas on how I can get access to the handle for the default windows cursor?
Doing Cursors.Arrow.Handle is the right code (internally it does a simple ::LoadCursor(IDC_CURSOR);
But, as I have already said, this call returns a HCURSOR.
What you were trying to do next is build a bitmap. That's a fine idea, but the API method you use expects an HICON, not an HCURSOR.
So you've got to find somewhere (either in the .NET API, or through WIN32) a way to convert the HCURSOR to an HICON. I guess that if that was only a matter of casting, this would not lead to an error.
What about lurking around Codeproject articles dealing with HCURSOR and HICON ?
Back to real work : D-19.
|
|
|
|
|
Believe me .S.Rod, I've tried and come up blank The easiest way (or the only way I can find) is to do it via Win32. That's ok except that I have no clue as to how to define the IDC_ARROW identifier in my .NET code. I couldn't find any articles on the topic. But thanks anyway. Perhaps I'll try and be content with my little hack
Cheers
Senkwe
ASP.NET can never fail as working with it is like fitting bras to supermodels - it's one pleasure after the next - David Wulff
|
|
|
|
|
Senkwe Chanda wrote:
That's ok except that I have no clue as to how to define the IDC_ARROW identifier in my .NET code.
public const int IDC_ARROW = 32512; // from winuser.h
|
|
|
|
|
Hi there, thanks, I'm aware of that It's using it that's a problem right now.
Cheers
Senkwe
ASP.NET can never fail as working with it is like fitting bras to supermodels - it's one pleasure after the next - David Wulff
|
|
|
|
|
I have been playing with ADO.NET and my connection object returns me a OleDbDataReader. How do I turn that into something I can bind to the DataGrid ?
Thanks for any suggestions.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Use the DataAdapter's Fill method to fill a DataSet then set the DataSource property of the grid to the DataSet you just filled.
[edit]Sorry its early, i'll get back with you on how to do it [/edit]
It pays if I look at the right class in the framework, use the OleDataAdapter class, passing in your OleDbCommand object; then use one of the Fill methods.
James
- out of order -
|
|
|
|
|
Hi
To add the James's response, the DBAdapter has a wonderfull Configure button Takes care of almost everything, but you mite need to modify the statements or procudures to your liking.
DataSets are really good timesavers , but there is a performance overhead (not that its really noticable on my PC anyways)
Cheers
"I dont have a life, I have a program."
|
|
|
|
|
Hi Guys,
I am looking for .NET training institute in bay area (Sunnywale,Santa clara or Fremont).
Please let me know if you know one.
Thanks
Anshul
|
|
|
|
|
Several people at work have done .NET courses. My advice - buy Programming the .NET Framework, Inside C#, and the ADO.NET and ASP.NET books from Microsoft. You'll learn more and it will cost less.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
I am unsuccessful in inheriting from this class. ControlBindingsCollection inherits from it and it has protected internal members implying it was designed to be inherited from. Yet, the compiler says there is no access to the constructor and the object browser does not show a constructor.
Alan
|
|
|
|
|
Shawn Wildermuth *just* answered your question, but I'll repost it here for those not on the DOTNET-WINFORMS[^] mailing list.
"The constructor is marked internal...that's how the ControlBindingsCollection inherits from it."
James
- out of order -
|
|
|
|