This sould be a reply..
John Baird
Posts
-
HotKey Indicator -
Serialization of a datatable using FileMode.AppendThanks for the help. Your suggestion did the trick. Didn't need to mess with the position as it was where it needed to be for the next deserialization. Thanks again.
-
Serialization of a datatable using FileMode.AppendHi: I am trying to serialize/deserialize a datatable in chunks (say every 10,000 records of a 250,000 record table) using the filemode.append functionality of the binary formatter stream object as follows: dt.RemotingFormat = SerializationFormat.Binary; BinaryFormatter formatter = new BinaryFormatter(); Stream output = new FileStream(path, FileMode.Append, FileAccess.Write, FileShare.Write)) formatter.Serialize(output, dt); This serializes the file to disk just fine. I can watch the size of the resulting disk file increase with each chunk added. When I attempt to deserialize the file, I only get the first chunk (1st 10,000 records) of data from the datatable and the rest is apparently ignored. Looking at the file in a hex editor, I can see header records for each appended set of records. I believe that the multiple headers are the problem. I know I have to be overlooking something simple. If you have seen this or solved this, please tell me what I need to do. Thanks for your time. John
-
c# Listbox helpOkay. I traced through the previously posted code and the data is actually being inserted into the table correctly and at the correct position. It is the DefaultView which is causing the list to display in the wrong order. I added the following to the method:
CurrencyManager cmSelect = (CurrencyManager)this.lstSelected.BindingContext(dtSelect); cmSelect.Refresh();
It runs without error, but nothing changes. Can anyone suggest another approach? -
c# Listbox helpI'm pulling out what little remaining hair I have again. I have a list box with 8 items, the selected item is highlighted at the top of the list. I press a button (cmdMoveDown) and wish to move the selected item 1 item down the list. I tried this:
public void MoveDown() { int index = this.lstSelected.SelectedIndex; int newindex = index + 1; DataTable dtSelect = (DataTable)this.lstSelected.DataSource; DataRow dr = dtSelect.Rows[index]; dtSelect.Rows.Remove(dr); dtSelect.Rows.InsertAt(dr, newindex); }
this removes the item at index 0 just fine. But the insert doesn't happen and there is a blank line at the bottom of the list. then i tried this variation:public void MoveDown() { int index = this.lstSelected.SelectedIndex; int newindex = index + 1; DataTable dtSelect = (DataTable)this.lstSelected.DataSource; DataRow dr = dtSelect.Rows[index]; DataRow drNew = dtSelect.NewRow(); foreach(DataColumn dc in dtSelect.Columns) drNew[dc.ColumnName] = dr[dc.ColumnName]; dtSelect.Rows.Remove(dr); dtSelect.Rows.InsertAt(drNew, newindex); }
this variation removed the selected item and added the new row at the end of the list rather than at new index. I tried various permutations of this code and could get nothing to work. Any suggestions? -
updating system time in c#I don't know anything about VB but you don't have the equivalent to the CType function call in the c# code. Is that necessary?
-
Application Global PropertiesThanks for your help. I've finally been able to get it to work. Dump it in favor of what? classes. There has been some discussion on speed using structures for static storage. It seems that most favor the structure. You reasons?
-
Application Global PropertiesThanks for replying, but I'm still lost. I'm trying to load the values into a static structure now. The values are loaded, but when I try to access them from the watchwindow, I get the "out of score" error. Pardon me, but here is the code. Can you tell me what's wrong?
using System; using System; using AMS.Profile; namespace MySpace { /// /// Summary description for AppStartUp. /// public class AppStartUp { public AppStartUp() { // // TODO: Add constructor logic here // } public struct AppDefaults { public static string server = ""; public static string dataBase = ""; public static string adminPath = "c:\vsdevelop"; public static string sqlConn = ""; } public static void SetAppDefaults() { Registry profile = new Registry(); AppDefaults.server = profile.GetValue("DBSettings","DBServer",""); AppDefaults.dataBase = profile.GetValue("DBSettings","DBName",""); AppDefaults.adminPath = "c:\vsdevelop"; AppDefaults.sqlConn = "SERVER=" + AppDefaults.server.ToUpper().Trim() + ";UID=uid; PWD=pwd;DATABASE=database"; } public static void LoadProgramSettings() { SetAppDefaults(); } } }
-
Application Global PropertiesThe classes are in different namespaces. I thought adding a reference to the individual namespaces would allow me access to the class from anywhere. Is that not true?
-
Application Global PropertiesHello: Is there a way to set application properties that are global and accessible from all points in the program. I have tried public static classes, constants, properties on the main form, properties in the app object, but it always tells me that the "prop" is not in scope. How do you guys handle this kind of problem for setting application wide defaults. It was easy in vfp, but i'm pulling my hair out here (what's left of it anyway). Thanks.