Results 1 to 11 of 11

Thread: [2.0] Slight issues here, classes - structures - arraylists - databases oh my...

Threaded View

  1. #7

    Thread Starter
    Member
    Join Date
    Apr 2006
    Posts
    56

    Re: [2.0] Slight issues here, classes - structures - arraylists - databases oh my...

    Pretty neat concept. Thanks.

    Here is what my main class looks like now. Seems ok, or could be setup better?

    clsMainClass code:

    Code:
    using System;
    using System.Collections;
    using System.Data;
    using System.Data.OleDb;
    using System.Windows.Forms;
    
      public class clsMain
      {
          private static ArrayList queryArray = new ArrayList();
    
          private static string ocs = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\db.mdb";
          private static OleDbConnection odc = new OleDbConnection(ocs);
    
          public clsMain()
          { }
    
          private static void QueryColumn(string which_table, string which_column)
          {
              queryArray.Clear();
              
              string SQL = "SELECT * FROM " + which_table;
              OleDbDataAdapter oda = new OleDbDataAdapter(SQL, odc);
              
              DataSet ds = new DataSet();
              oda.Fill(ds);
    
              foreach (DataTable dt in ds.Tables)
              {
                  foreach (DataRow dr in dt.Rows)
                  {
                      queryArray.Add(dr[which_column]);
                  }
              }
    
              odc.Close();
          }
    
          public struct ProgramSettings
          {
              public string psWindowLocation;
    
              public static ProgramSettings Load()
              {
                  ProgramSettings obj;
    
                  clsMain.QueryColumn("tProgramSettings", "SettingsValue");
    
                  obj.psWindowLocation = queryArray[0].ToString();
    
                  return obj;
              }
    
              public void Save()
              {
                  // Save properties of 'this' to file here.
              }
          }
      }
    frmMain code:

    Code:
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    
      public partial class frmMain : Form
      {
          clsMain.ProgramSettings ps = clsMain.ProgramSettings.Load();
          
          //[STAThread]
          static void Main()
          {
              Application.EnableVisualStyles();
              Application.SetCompatibleTextRenderingDefault(false);
              Application.Run(new frmMain());
          }
          
          public frmMain()
          {
              InitializeComponent();
    
              // Load the program settings.
              MessageBox.Show(ps.psWindowLocation.ToString());
          }
      }
    Last edited by ThisIsMyUserName; Apr 15th, 2006 at 01:44 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width