Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

Azerax

@Azerax
About
Posts
7
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Save inside a file ArrayList code
    A Azerax

    Check out these two functions for serializing and deserializing data using a BinaryFormatter. It serializes a hashtable but can be replaced by an arraylist and should work just fine. static void Serialize() { // Create a hashtable of values that will eventually be serialized. Hashtable addresses = new Hashtable(); addresses.Add("Jeff", "123 Main Street, Redmond, WA 98052"); addresses.Add("Fred", "987 Pine Road, Phila., PA 19116"); addresses.Add("Mary", "PO Box 112233, Palo Alto, CA 94301"); // To serialize the hashtable and its key/value pairs, // you must first open a stream for writing. // In this case, use a file stream. FileStream fs = new FileStream("DataFile.dat", FileMode.Create); // Construct a BinaryFormatter and use it to serialize the data to the stream. BinaryFormatter formatter = new BinaryFormatter(); try { formatter.Serialize(fs, addresses); } catch (SerializationException e) { Console.WriteLine("Failed to serialize. Reason: " + e.Message); throw; } finally { fs.Close(); } } static void Deserialize() { // Declare the hashtable reference. Hashtable addresses = null; // Open the file containing the data that you want to deserialize. FileStream fs = new FileStream("DataFile.dat", FileMode.Open); try { BinaryFormatter formatter = new BinaryFormatter(); // Deserialize the hashtable from the file and // assign the reference to the local variable. addresses = (Hashtable) formatter.Deserialize(fs); } catch (SerializationException e) { Console.WriteLine("Failed to deserialize. Reason: " + e.Message); throw; } finally { fs.Close(); } // To prove that the table deserialized correctly, // display the key/value pairs. foreach (DictionaryEntry de in addresses) { Console.WriteLine("{0} lives at {1}.", de.Key, de.Value); } } Elvis (a.k.a Azerax) Life is Music listen to it before it fades

    C# csharp xml question

  • Displaying data from 2 Tables in one Grid
    A Azerax

    I guess the best way to do it is to combine the data from the two tables into one using a join in the query used to retrieve it. And then you can bind the dataTable to the Grid. Elvis (a.k.a Azerax) Life is Music listen to it before it fades

    C# question css

  • Cannot get value because it is DBNull
    A Azerax

    Ohh I am sorry I got it wrong again . Please note the corrected code as follows: dtpBirthday.Value = dsPlayer.Tables["Players"].Rows[0]["Birthday"]== DBNull.Value ? DateTime.Now : dsPlayer.Tables["Players"].Rows[0]["Birthday"].ToString() ; Sorry for the trouble... Elvis (a.k.a Azerax) Life is Music listen to it before it fades

    C# question database

  • Cannot get value because it is DBNull
    A Azerax

    Ohh I am sorry :(. Please note the corrected code as follows: dtpBirthday.Value = dsPlayer.Players[0]["BirthDay"]== DBNull.Value ? DateTime.Now : dsPlayer.Players[0]["Birthday"].ToString() ; Where birthday is a field in your dataTable. Elvis (a.k.a Azerax) :cool: Life is Music listen to it before it fades

    C# question database

  • Redim Arrays in C#
    A Azerax

    I have written a function for a similar purpose that creates a dynamic array. Here Check this out: _/// /// Function to add an array element to a dynamic Array /// /// Dynamic Array /// Element to add to the dynamic array /// array with the element appended to it_ public static Array RedimNPreserve(int[] Arr,int Element) { System.Collections.ArrayList al = new System.Collections.ArrayList(); int i; if(Arr!=null) { for(i=0;i<=Arr.GetUpperBound(0);i++) { al.Add(Arr[i]); } } al.Add(Element); return al.ToArray(typeof(int)); } Elvis (a.k.a. Azerax) Life is Music listen to it before it fades

    C# csharp data-structures question

  • Cancel closing a form
    A Azerax

    Cancelling the closing of a form is quite simple and can be implemented as follows: protected void Form1_Cancel (Object sender, CancelEventArgs e) { if (!myDataIsSaved) { e.Cancel = true; MessageBox.Show("You must save first."); } else { e.Cancel = false; MessageBox.Show("Goodbye."); } } Elvis (a.k.a. Azerax) Life is Music listen to it before it fades

    C# help tutorial question

  • Cannot get value because it is DBNull
    A Azerax

    How about trying this? dtpBirthday.Value = dsPlayer.Players[0].BirthDay.ToString()== DBNull.Value ? DateTime.Now : dsPlayer.Players[0].BirthDay ; This is an example of a conditional if statement and will best suit your purpose. The Conditional Statement variable = op1 == op2 ? trueValue : FalseValue ; where: op1 == op2 is your condition Life is Music listen to it before it fades away

    C# question database
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups