Archive

Archive for January, 2005

Configuration files for windows forms

January 20, 2005 Leave a comment

I often found that it was time consuming, when putting together a "Throw-away" application, that so much UI plumbing was required – with check boxes, text boxes, listboxes etc. were required to allow some sort of user configurability. Of course, a UI is required for a public App., but for personal use, I thought it might be handier to use an XML file, slapped into the same Bin folder as the executing assembley.

So for instance, with an XML file like

<root>
 <websites>
  <website/>…
 </websites>
 <files>
  <file/>…
 </files>
</root>

I put this function in to rhe main function

public void readConfigXml()

{

string path = System.IO.Path.GetDirectoryName(

System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );

path = path.Substring(6);

FileStream xmlFile =

new FileStream(path + "\config.xml",FileMode.Open);

string xmlContent = new StreamReader(xmlFile).ReadToEnd();

xmlFile.Close();

XmlDocument doc = new XmlDocument();

doc = new XmlDocument();

doc.LoadXml(xmlContent);

XmlElement root = doc.DocumentElement;

websites = root.ChildNodes[0].ChildNodes;

files = root.ChildNodes[1].ChildNodes;

}

 

 

 

 

 

 

 

Categories: Uncategorized

Problem with SQL Wrapper

January 16, 2005 Leave a comment

As I mentioned earlier, I was looking for a way to add SQL caching capabilities easily into .NET without upsetting, too much code – So I started off with a simple Query/Analyser program –

private void button1_Click(object sender, System.EventArgs e)

{

DataSet resultSet = ExecuteDataSet(this.tbSql.Text,this.tbConnectionString.Text);

this.dataGrid.DataSource = new DataView(resultSet.Tables["sql"]);

}

public DataSet ExecuteDataSet(string sql,string connectionString)

{

DataSet ds = new DataSet();

SqlConnection DSN = new SqlConnection(connectionString);

DSN.Open();

SqlCommand Database = new SqlCommand(sql,DSN);

SqlDataAdapter Adapter = new SqlDataAdapter(Database);

Adapter.Fill(ds,"sql");

DSN.Close();

return ds;

}

 

Then. tried to create a namespace called CachedSqlClient, which would take all the classes from SqlClient, but modify and extend them to support caching, my first attempt being:

using

System;

using System.Data;

using

System.Data.SqlClient;

namespace CachedSqlClient

{

public class SqlConnecion : System.Data.SqlClient.SqlConnection

{

}

}

But I got the error

C:Documents and SettingsadminMy DocumentsVisual Studio ProjectsBootstrapSQLCacheCachedSqlClientClass1.cs(10): ‘CachedSqlClient.SqlConnecion’ : cannot inherit from sealed class ‘System.Data.SqlClient.SqlConnection’

Categories: Uncategorized

About this blog

January 15, 2005 1 comment

This blog, is an experiment, and a list of random thoughts and ideas that come into my head whilst developing my main site http://network.programming-in.net

I was intending to write an article on one of the following

  • Windows Firewall API
  • DirectPlay API
  • HttpListener

Or perhaps, a SQL Caching utility (where common, lengthy SQL queries & responses would be cached to disk, for a pre-determined length of time).

Categories: Uncategorized