Learning (RSS)

Borring school stuff and learning stuff

My first open source project Office Open XML C# Library

Hey all,

Well today i finally started my own Open source project witch is called "Office Open XML C# Library".

The purpose of this project is to create a Library witch will allow c#(.Net 2.0) programmers a easy interface with the new File format of Office 2007.

As a start i created a basic interface for word documents (*.docx) witch is in the Alpha fase. This interface is not great Yet but it will to some of the basic thinks like reading and writing :).

In the end the Library will support all the Open Xml files like "Docx", "xlsx" and the rest of it all.

One of the problems with the first alfa is you can't create a docx from scratch yet.

Well i hope some people think this is a good idee :D.
If to please visit http://officeopenxml.sourceforge.net and try it out

Happy Netting,
Warnar

I Love Scutt

Hi all,

I just wane say subscribe to this blog: http://weblogs.asp.net/scottgu/ (if you havent allready)
And some more information you really need to take a look at http://weblogs.asp.net/scottgu/archive/2006/05/08/445742.aspx it's web applications back a well it has been back for a while i'm just late blogging.

Happy netting!

Object to DataTable

Hi all, Did you ever had the problem that u just wanted your object in a datatable and didn't wane hardcode the datatable if so this may help:

#region ObjectArrayToDataTable
        internal static DataTable ObjectArrayToDataTable(object[] obj, Type type)
        {
            return ObjectArrayToDataTable(obj, type, null);
        }
        internal static DataTable ObjectArrayToDataTable(object[] obj, Type type, DataColumn[] extra)
        {
            DataTable dt = new DataTable();

            foreach (PropertyInfo pi in type.GetProperties())
            {
                if (pi.PropertyType.IsPrimitive || pi.PropertyType == typeof(string) || pi.PropertyType == typeof(DateTime))
                {
                    dt.Columns.Add(pi.Name, pi.PropertyType);
                }
            }

            if (extra != null)
            {
                foreach (DataColumn c in extra)
                {
                    if (dt.Columns.Contains(c.ColumnName))
                        dt.Columns.Remove(c.ColumnName);
                    dt.Columns.Add(c);
                }
            }

            foreach (object k in obj)
            {
                DataRow dr = dt.NewRow();
                foreach (PropertyInfo pi in type.GetProperties())
                {
                    if (pi.PropertyType.IsPrimitive || pi.PropertyType == typeof(string) || pi.PropertyType == typeof(DateTime))
                    {
                        dr[pi.Name] = pi.GetValue(k, null);
                    }
                }
                dt.Rows.Add(dr);
            }

            return dt;
        }
        #endregion

I wish you all happy netting!

Border-radius in IE

Hi all,

Long time since i posted but well i should do it so here i go again i think :D
I was working on a site that needed rounded borders that could change color on the fly so for mozilla i found the css propertie -moz-border-radius but this didn't work so after some searching i found a hack i dunno where exactly anymore but here is the htc file that you should use if you wane let ie be possible to use a border radius:

- htc file
- html preview file

hope this help some ppl

Happy netting,

Warnar

Make IE and Mozzilla look the same (2 tips)

Hi all,

So i was building my cms system and finally i found out what was wrong and why a site looked so mutch differend in IE then in Mozzila.
The problem is the Box model used by IE the official box model by W3C is with of the content but IE uses the width of the border.
To fix this is pritty easy just dump IE! No just kidding there is a very nice think make by Erik Arvidsson witch will make the images with borders look the same in IE and Mozzilla. The site where you can read about this is: http://webfx.eae.net/dhtml/boxsizing/boxsizing.html

Also what really f*c*s sites up is the user of the css properties 'font-size' used with one of the following values:

  • xx-small
  • x-small
  • small
  • medium
  • large
  • x-large
  • xx-large

Just use number as values like '12px' or '16px'.

These 2 tricks really helped me create a system that makes the sites look almost the same.

Happy netting,
Warnar Boekkooi

Arraylist to String[]

Hi all,

Just had the problem of that i needed to make a arraylist to a string array this is the way i did it:

string[] test = frames.ToArray(Type.GetType("System.String")) as string[];

In this case frames is the arraylist;

Javascript Style Sheet change function

Hey all,

The last couple of hours i have been bizzy with some stupid control that i needed that could change the background color, font color and stuff of a StyleSheet so here is the result (i tested it in Firefox and IE):

function StyleSheetChanger(cssClassName,toChange,changeTo)
{
 for(i = 0; document.styleSheets.length > i; i++) //Mozilla
 {
  if(document.styleSheets[i].rules != undefined)
  {
   for(j = 0; document.styleSheets[i].rules.length > j; j++)
   {
    if(document.styleSheets[i].rules[j].selectorText.toLowerCase() == cssClassName)
    {
     document.styleSheets[i].rules[j].style[toChange] = changeTo;
    }
   }
  } else if(document.styleSheets[i].cssRules != undefined) //IE
  {
   for(j = 0; document.styleSheets[i].cssRules.length > j; j++)
   {
    if(document.styleSheets[i].cssRules[j].selectorText.toLowerCase() == cssClassName)
    {
     document.styleSheets[i].cssRules[j].style[toChange] = changeTo;
    }
   }
  } else
  {
   window.alert("Your browser won't support the changing of a style sheet by javascript!");
  }
 }
}

The way that it works is that it will go true all the Style's you have and look for the cssClassName (or what ever it is called) like Body or .MyStyle and change the the propertie of it that you wane change like the background and that's it.

btw dues any one know a good edit for JavaScript because i hate using notepad for stuff like this.

Happy Netting,
Warnar

Stupid OleDbCommand.Parameters

Hi all,

Men i have been f*cking up today i had some nice OleDbCommand lbut one way or the other the paramaters didn't work right it looked like this:

OleDbCommand SelectCommand = new OleDbCommand("SELECT DesignID, Name, TextColor, BackGroundAlign, BackGroundColor, BackGroundImage, BackGroundRepeat FROM DesignFrames WHERE (DesignID = ?) AND (Name = ?)",this.oleDbConnection1);

SelectCommand.Parameters.Add(new
System.Data.OleDb.OleDbParameter("Name", System.Data.OleDb.OleDbType.Integer));

SelectCommand.Parameters.Add(
new System.Data.OleDb.OleDbParameter("DesignID", System.Data.OleDb.OleDbType.Integer));

After spending about 1 hour i find out that with OleDbCommand the order of the Parameters mather so great yet another hour wasted on notting. My code now looks like this:

OleDbCommand SelectCommand = new OleDbCommand("SELECT DesignID, Name, TextColor, BackGroundAlign, BackGroundColor, BackGroundImage, BackGroundRepeat FROM DesignFrames WHERE (DesignID = ?) AND (Name = ?)",this.oleDbConnection1);

SelectCommand.Parameters.Add(new System.Data.OleDb.OleDbParameter("DesignID", System.Data.OleDb.OleDbType.Integer));

SelectCommand.Parameters.Add(new
System.Data.OleDb.OleDbParameter("Name", System.Data.OleDb.OleDbType.Integer));

Happy Netting,
Warnar Boekkooi

Get all selected values checkboxList

Hey all,

I had a small problem when working with a check box list  because when you say CheckBoxList1.SelectedValue you only get the first value selected not all the selected values.
To get all the selected values u will need to go true all the items like the following code dues

foreach(ListItem item in ((CheckBoxList1)Page.FindControl(dr.id.ToString())).Items)
{
    if (item.Selected)
    {
           Label1.Text += item.Value+“, “;
     }
}

Why isn't there just a way to get like CheckBoxList1.SelectedValues and get back a array with all selected values? A wll you can't have it all

Happy netting,
Warnar

Moving a Row up in a Datatable

Hey all,

I was bizzy with a little project and it needed to move row's up and down in a Datarow.
Problem was i couldn't move the datarows so i needed to move the info.
The way i moved a row up was like this (this happend in ItemCommand with a command named Up):

object[] up = DataTableFields.Rows[e.Item.ItemIndex].ItemArray;
object[] down = DataTableFields.Rows[e.Item.ItemIndex-1].ItemArray;
DataTableFields.Rows[e.Item.ItemIndex].ItemArray = down;
DataTableFields.Rows[e.Item.ItemIndex-1].ItemArray = up;

Don't really like this way but hey it works.

Happy netting,
warnar

No LIMIT in MSSQL how to do the same

Hey all,

I was having the small problem with a site with alot of records in the DB and well i pulled them out every time the site was shown but it was only showing 10 records not all.
The problem was that i could use the same SQL as in ASP.NET DataGrid Paging Part 2 - Custom Paging because i neede couldn't use ID's that way.

So i neede to get 10 records sort the data and put it on the site :) here is how to get 10 records from the database:
SELECT * FROM KK.dbo.brand WHERE brandID IN(SELECT TOP 10 brandID FROM(SELECT TOP @Rows brandID FROM KK.dbo.brand ORDER BY brandID) A ORDER BY brandID DESC) ORDER BY brandID

Ok what are we doing here?

We are first getting the top x rows witch in my case is a int called @Rows and order them with the brandID (SELECT TOP @Rows brandID FROM KK.dbo.brand ORDER BY brandID)

Second we take that info and turn it around and ask for the top 10 records so now we have the record we need but up site down (SELECT TOP 10 brandID FROM(SELECT TOP @Rows brandID FROM KK.dbo.brand ORDER BY brandID) A ORDER BY brandID DESC)

So last think to do is turn and turn all around :D and that's what we do last and then you get:
SELECT * FROM KK.dbo.brand WHERE brandID IN(SELECT TOP 10 brandID FROM(SELECT TOP @Rows brandID FROM KK.dbo.brand ORDER BY brandID) A ORDER BY brandID DESC) ORDER BY brandID

Cool aint it?
Dues anyone know if LIMIT will be in the new mssql?

Happy Netting,
Warnar

 

Server Error in '/' Application. Parser Error (Don't you love this :p)

Hey all,

I got a small job from www.proctrl.nl for one of there sites.
When in plementing the ASP.NET app i got the following error:

Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'ExcelPriceList.price'.

Source Error:

Line 1:  <%@ Page language="c#" Codebehind="price.aspx.cs" AutoEventWireup="false" Inherits="ExcelPriceList.price" %>
Line 2:  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
Line 3:  <HTML>

Source File: d:\internet\root\www\burgerhout\www\prijzen\price.aspx    Line: 1

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

The way to make sure not to get this error is make the dir your putting the app in a virtual one :D

Happy netting,
Warnar

Get info from a Excel file using ASP.NET

Hey all,

I got a small job that has a XML file that should be displayed and i'm not in the mood of typing how i did it so here are the links i used:

http://www.c-sharpcorner.com/Code/2004/June/AccessExcelDb.asp (Mostly used the screenshot from the Excel file)
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B306572 (What to say it's the microsoft way and it works)

Hope that this may help :D

Happy Netting,

Warnar

N00B Mistake with a Component used for a Database (To mutch Database connections)

Hey all here is yet a again one of my blog about what i'm doing wrong :D

I have been bizzy with www.kapperkapper.nl as you may know. The problem is that i got error's that where like all connections to the database are open and stuff like that and i was Like WHAT!

I have a Component with all the dataset's adapters and code to use for the db on it i had my constructor witch opens the database and i had my dispose witch closes it.

A well it seemed to me that that should do the job but hey stupid me the Dispose is only called then ASP.NET thinks it is needed or what ever but not when i think it is needed.

So to fix this not i do:

using(ClientDB.Database db = new ClientDB.Database())
{
//Some stuff todo with the DB
}

Now the class is opend and disposed when the using stop's and Bug fixed :D

Happy Netting

Warnar

b.t.w. If you have any Tips for using MSSQL or related stuff me Please post them here :)

No IIS6 on Windows XP what a Big Bummer!

Hey,

I have just started installing PC for Gaming Only :D and also server for testing apps.
So me as smart as i am i ws thinking Windows XP with IIS6.

There is only one problem NO IIS 6 for XP why not????
I can't get a licence form school they don't sell Windows 2003 :(

Same question as here:  http://weblogs.asp.net/cszurgot/archive/2004/05/11/129989.aspx to microsoft why is there not IIS 6 for XP
Or is there a way??If there is please tell Thanks allready

Happy netting,

Warnar

Putting my app on the web problems :(

Hey i had/have some problems with my host and stuff :(

The first one was that i needed to get my DB from home onto the server of the webhost.
There are a couple of ways to do this you can use the Import and Export Data that is with your SQL server then you can select your host that you want to copy the data from after that you can select the server where you want the data to and then the way to copy it pritty Straight forward, but the problem i had with it was that some options like auto increment didn't get tranfered so i found my self a other way.

I opened Enterprise Manager and generated a SQL query from the DB i had after that i opened Query Analyzer and connected to my Server DB and executed the sql that i generated, then i found yet a problem witch i fixed manualy the Primary Keys did get transfert right.

The second problem was i had some problem with my mail server on the host and i had a nice Try Catch but i just wanted to comment it out witch i did but it didn't work and didn't work and i was going mad until Peter told me that i needed to build at my local pc and not just upload the .cs but also the projects .dll and the problem was Fixed :D:D:D

That was it for now will get back with more stupid bull s**t
Happy Junking later

Can Send mail (503 This mail server requires authentication)

Hey all,

I'm finaly in the completing fase of my school project YAY :D
I wrote a blog Sending Mail using C# a while ago and a well now i'm having the problem on my server that i can't send mail this is because i need to send some login info for the mail server the way to do this is following (MMessage is the Mail message):

MMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
MMessage.Fields.Add("
http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
MMessage.Fields.Add("
http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here

I got this solution on http://systemwebmail.com/faq/3.8.aspx so if you need some more info get it there :)

Happy Netting

Flash and XML

Hey all I have a project that maybe will use PHP,Mysql but they aren't sure yet if they want to use Flash or HTML and because I'm young and very impatient i allready wanted to start so what is the way