Nerseus
*Experts*-
Posts
2607 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Nerseus
-
I think a modal form (with ShowDialog) does not call Dispose. You can Dispose of a modal form either by calling dispose in the modal form's Closed event, or in the opening form's code, after the ShowDialog line (after you've referenced everything you need from the modal form). I'm pretty sure the Connection object will dispose when you call Close. There are only a handful of objects that support a Close method and I would bet that *most* of them will dispose of any resources they keep open (files, database connections, and forms are the three main ones). -Nerseus
-
// Fill an array for testing string[] strings = new string[10]; for(int i=0; i<strings.Length; i++) strings[i] = (i * 13).ToString(); for(int i=0; i<strings.Length; i++) Console.Write("{0,10}", strings[i]); Console.WriteLine(); You can use "{0,-10} in the Console.Write call to left-align. You can use the same format with String.Format as with Console.WriteLine, so: string s1 = string.empty; // Fill an array for testing string[] strings = new string[10]; for(int i=0; i<strings.Length; i++) strings[i] = (i * 13).ToString(); for(int i=0; i<strings.Length; i++) s1 += String.Format("{0,10}", strings[i]); Console.WriteLine(s1); -Nerseus
-
I just tried dexplore.exe but it doesn't appear to be keeping my cookies. At least, every time I come to this site, I must log in again. I like the tabbed look though... -Nerseus
-
You can use String.Format(), or for each individual string you could try stringvar.PadLeft() or stringvar.PadRight(). -Nerseus
-
Try: Select * From [Counter] where [pwd] = Also, you're better off listing out the columns you want instead of using *. First, because you can easily see what columns exist, and second because you can bracket them as well, in case their names are reserved words. Select [FirstName], [LastName] From [Counter] Where [Pwd] = ... -Nerseus
-
Can you post your project? I cannot duplicate this in either .NET 1.0 or .NET 1.1. -Ner
-
You can use ToString("c") with a new NumberFormatInfo object, ToString("$0.00"), or another variant of ToString with a specific format. For example: double d = -123456789.1234; NumberFormatInfo formatter = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone(); formatter.CurrencyNegativePattern = 1; Debug.WriteLine(d.ToString("c", formatter)); Debug.WriteLine(d.ToString("$###,###,##0.00")); Debug.WriteLine(d.ToString("$0.00")); This prints: -$123,456,789.12 -$123,456,789.12 -$123456789.12 The reason you get parens on your negative number is that the default number provider is from InvariantInfo. To override that, you need to create your own NumberFormatInfo object. In the code above, I clone the InvariantInfo and change the negative pattern from 0 to 1 (check the help for other formats). There's probably a way to get the setting from the user's machine, but I'm just not sure :) -Nerseus
-
XML can only have one root node. You normally stick your tables and/or rows under that. If you create a DataSet, you can see it's XML representation by using: myDataSet.GetXml() or write it to a file with myDataSet.WriteXml() -Nerseus
-
I tried at one time to create a TabPage as a separate class, complete with GUI design. The idea was that we may have 2 or more developers working on a complex form but with sourcesafe, only one developer could work on the form at once. Try as I might, I couldn't get the designer to show a TabPage. Even if that were possible, having the individual tab pages in a separate class gave us new problems that I won't go into. Suffice it to say, it didn't work out. In the end, using #region is the best option for splitting up most GUI code. You can definitely break out some code into common functions (such as filling a listbox or combobox, for instance), but there will still be a LOT of code for complex GUI forms. -Nerseus
-
What do you want to do? -Ner
-
Error: 5 Security Error connecting to DB
Nerseus replied to MarkD's topic in Database / XML / Reporting
Make sure you don't have the database open in Access when you run your program. I think the default method of opening a connection in Access is non-shared (exclusive). If you have it open in Access, it won't let you open it through .NET. Otherwise it looks like a good connection string. If you want, you can use JUST "User ID=Admin;" - no need to specify the password, though you could use ";Password=;" if you want. -Nerseus -
I can't really help with your problem, but I can offer some insight (maybe). First, the "lockup" problem you experience when modifying the null values to something else in a textbox is usually caused by untrapped errors. I've noticed what you're seeing when I have bound controls that try to write invalid data to the dataset. With some 3rd party controls, in some scenarios, there is no exception being thrown, no messagebox, and no JIT runtime error - it just "sticks" focus on the textbox. But, this problem will go away (hopefully!) once the other error is corrected. I can't see any reason why you couldn't put a valid date value in the date column unless that was your join column (which I would find hard to believe since it's a date). You're probably right in that it has something to do with the binding to a relationship instead of a table or a DataView. I have no experience there so I'm not sure what the problem might be. I'd suggest using the call stack when your program gets the exception (when setting the column to DateTime.Now). Also, search microsoft's support forum - this might be a known issue or just something you can't do. -Nerseus
-
In your case, I'd suggestion using the Copy method instead of Clone. Then just delete the ones you don't want. I don't think you can use Rows.Add(...) with a row that belongs to another dataset. The Add method doesn't create a new instance of a row - it needs an existing instance. You'll have to use the datatable's NewRow method to get a new instance of a datarow then populate that new row with data from the original datarow. I don't remember offhand if you can do that in one step or if you need to loop through every column and copy the contents. Hence my suggestion for a Copy and Delete instead :) -Nerseus
-
Yes, Cassio. You can fill a datagrid from almost anything, but you must do so through binding. Assuming you're binding the grid to a DataSet, you'd have to fill your dataset from the datareader - which is mostly pointless :) -Nerseus
-
Converting Millimeters to Pixels using VB.NET
Nerseus replied to esteuart's topic in Graphics and Multimedia
72 dpi is normal for a monitor? Maybe just in England...? My monitor says "Normal Size 96dpi". I guess it's another reason to not worry too much about the exact size on the screen :) -nerseus -
I have never seen the behavior you're talking about, Nickels. I know that Now() is a holdover from VB6. Maybe try "... = DateTime.Now" instead? If that doesn't work, maybe you could post your code with a SQL snippet for the CREATE TABLE so we can test it. I assign DateTime.Now to SQL Server DateTime variables all the time. Also, it doesn't matter if your database column allows nulls or not since you're assigning a date. If you wanted to assign System.DBNull.Value to the column, then you'd have to make sure the column allows nulls. -ner
-
Actually, a_jam_sandwich asked me how I did the INSERT and SELECT @@IDENTITY in Access. Turns out, I didn't - never tried it in Access (don't work with it much, just assume it worked). Maybe there is a way to do the INSERT and SELECT, but I couldn't get it to work :) Looks like two separate calls are needed. I guess that's one more reason Access isn't great on multi-user performance. -Nerseus, /chants MSDE, MSDE, MSDE...
-
Search for "SetWindowsHookEx MessageBox" in Google, you'll find lots of answers. But overriding the position of the MessageBox is not simple as it involves windows hooks. Most of the articles you'll find will give good sample code though, so you don't have to worry too much. -nerseus
-
First, you don't need to make the string filename static. You can simply make it private and set it in buttonSetFile and use the value (to pass to formTables) in buttonTables_click. If you want to get fancy, name the variable something like _filename and add a private property to your form named Filename. In the "Set" portion of the property, you can enable the buttonTables button if the Value.Length > 0 (not an empty string). That way you can handle enabling/disabling buttonTables - assuming you want it disabled until they pick a file. To get the tables selected from formTables is simple. Expose whatever it is you "select" on formTables as a public field (variable or property). Set that property on formTables just before you close the form. Then on formMain, you can read the property and do what you need with it. For example, suppose you want formTables to "return" an array of strings that are the table names. On formTables, add the following: // Put this at the top, as a public field public string[] Tables; private void btnOk_Click(object sender, System.EventArgs e) { Tables = new string[listBox1.SelectedItems.Count]; for(int i=0; i<listBox1.SelectedItems.Count; i++) Tables[i] = listBox1.SelectedItems[i].ToString(); this.DialogResult = DialogResult.OK; this.Close(); } Then in formMain: private void btnShowTables_Click(object sender, System.EventArgs e) { formTables frm = new formTables(filename); frm.ShowDialog(); if(frm.DialogResult==DialogResult.OK) { foreach(string s in frm.Tables) ... } frm.Dispose(); } -Nerseus
-
There are basically two ways to view the data in a DataSet in a sorted order. You can use a DataView (including the one built into the DataTable), or you can use the Select method of the DataTable. What are you doing with the DataSet? If you're binding, you'll want a DataView. You can sort the table's built-in dataview with this: myDataSet.Tables["Table1"].DefaultView.RowFilter = "FirstName like 'j*'"; If you just need to loop through the rows in a sorted order to process them, use this: DataRow[] rows = myDataSet.Tables["Table1"].Select("FirstName like 'j*'"; foreach(DataRow row in rows) // Do something with row -ner
-
Converting Millimeters to Pixels using VB.NET
Nerseus replied to esteuart's topic in Graphics and Multimedia
I'll throw this out for you - if you really want to get it to appear as the exact millimeter size on the screen, you'll need to know the monitor size as well. And not just 17" or 19" or 21" (for lucky people like me :)), but how much of that is visible, do they have a black border around the edge, etc. The point is, you won't be able to get exact. Now, if you final destination is a printer or other output device, there are methods to scale your pixel dimensions to millimeters for a printer, which WILL be exact (assuming the math is right and the printer is accurate enough). Trying to get an EXACT size on a monitor is close to a lost cause in my opinion. -Nerseus -
To be honest, I'm not sure of the difference. Looking at the Call stack, there's different internal .NET code running to fire the Validating event. Something in there isn't being caught or letting you catch it - I'm not sure which. I've seen a similar problem when using DataBound controls. I had a grid control bound to a DataSet. During the changing of some data in the grid, I perform some validation and run through some fee calculation code. The fee calculation code might add/remove records from my dataset, which triggers another change event in my grid. Everything seems to work fine except there's an exception that I can't catch because it happens outside of any trappable code. By examining the callstack, I was able to figure out that the grid still had a reference to a row in my DataSet that was no longer valid since that row had been deleted somewhere down the line. The point is this: in the above code, there was no place I could put a try/catch block to trap the error. But by using the call stack I could see what code was throwing the exception and then work on preventing the exception from happening in the first place. In your scenario, it seems likely that you could catch the exception at a higher level (in the validating event possibly) or even do manual checking of the data to prevent an exception. Of course, if you feel that there's a bug in .NET that's causing the unhandled JIT error, you can always call MS support. If you have an MSDN subscription you get a free support call (maybe a few). Or, search http://support.microsoft.com for free. And there's always .NET 1.1 which just came out - you might try your sample code there, too, to see how it behaves. -ner
-
Do you, by chance, only have one user in the listbox and after the delete you have none? If so, you're "If ArryEditUsers.Count > 0 Then" won't reset the datasource. Also, why in the world are you using ADODB.Recordset??? I refuse to test this code out of principal. If you fix it to use ADO.NET I'll try and duplicate this to see what the problem might be :p -Nerseus
-
I'd look at a couple of options. First, maybe your code be auto-updating. You'd have to manually code this to go out and check for new versions and download them automatically. It may take a week or so to get working well, but will definitely pay off in the long run if you have lots of updates and lots of users. You could also have the network admin set up a login script for each user so that when they login it runs your setup program (and possibly uninstalls the old one). A bit trickier and the user wouldn't get the latest version until they logged out/in. You could also point your users to a web address to launch the EXE. .NET has built-in support for running a WinForms app launched from a web site which includes automatically downloading DLLs as needed. There are some issues of course :) If you're interested, check out this article and this article. -Nerseus
-
You mean you get this when you type in that path from Start->Run? If so, it's not a .NET issue but a network issue. If you can reach it from Start->Run then I see no reason why .NET would handle it differently, unless you're running a web-based WinForm app (or something similar) which might have restrictions. But, if you're just giving your user an executable (either directly or installed through a setup program - but NOT through the web), then it should be ok. -Nerseus