<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4310766517884285175</id><updated>2012-02-16T15:38:16.227+01:00</updated><category term='Mail'/><category term='Random'/><category term='flash'/><category term='MemoryStream'/><category term='charts'/><category term='wrapper'/><category term='ConfigurationSettings'/><category term='CSS'/><category term='PDF'/><category term='ODP'/><category term='AppSettings'/><category term='.resources'/><category term='GridView'/><category term='.resx'/><category term='Encrypt'/><category term='UUdecode'/><category term='flex'/><category term='oracle'/><category term='iTextSharp'/><category term='C# ASP.NET'/><category term='UDT'/><category term='MD5'/><category term='UUencode'/><category term='actionscript'/><category term='why'/><category term='JavaScript'/><category term='DIV'/><category term='Password'/><category term='MS Word'/><category term='ConfigurationManager'/><title type='text'>Sjoerd Perfors - Software Development Headaches</title><subtitle type='html'>From frustrating simple problems to complex never ending google searches.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-7686207140489942742</id><published>2008-06-11T09:24:00.009+02:00</published><updated>2008-06-13T10:36:15.097+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MS Word'/><category scheme='http://www.blogger.com/atom/ns#' term='C# ASP.NET'/><title type='text'>C# Creating MS Word documents</title><content type='html'>In this post i will show you how to create a simple word document with the COM library. For this you will need MS Word installed on your computer in order to get it work.&lt;br /&gt;&lt;br /&gt;First we need to add a reference to the project: right-click project -&gt; add reference -&gt; COM -&gt; Microsoft Word 12.0 Object Library -&gt; Add &lt;br /&gt;&lt;br /&gt;Earlier versions should work also, i have Office 2007 installed so i have the 12.0 library. If you want to create documents which work on Office 97 then get an earlier library.&lt;br /&gt;&lt;br /&gt;First we add a reference to the class:&lt;br /&gt;&lt;br /&gt;using Microsoft.Office.Interop.Word;&lt;br /&gt;&lt;br /&gt;Then in our function we create the document:&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;             {&lt;br /&gt;            object fileName = "D:\\helloworld.doc";&lt;br /&gt;            object novalue = Missing.Value;&lt;br /&gt;&lt;br /&gt;            ApplicationClass objWord = new ApplicationClass();&lt;br /&gt;            Document objWordDoc = objWord.Documents.Add(ref novalue, ref novalue, ref novalue, ref novalue);&lt;br /&gt;            objWordDoc.Activate();&lt;br /&gt;&lt;br /&gt;            object start = 0;&lt;br /&gt;            object end = 0;&lt;br /&gt;            Range myRange = objWordDoc.Range(ref start, ref end);&lt;br /&gt;&lt;br /&gt;            myRange.InsertParagraphBefore();&lt;br /&gt;            myRange.InsertBefore("Hello world");&lt;br /&gt;            //Add shading&lt;br /&gt;            myRange.Shading.BackgroundPatternColor = WdColor.wdColorLightOrange;&lt;br /&gt;            myRange.Font.Name = "Arial";&lt;br /&gt;            myRange.Font.Size = 18;&lt;br /&gt;            myRange.ParagraphFormat.SpaceAfter = 0;&lt;br /&gt;&lt;br /&gt;            //Next paragraph style, first set the range.&lt;br /&gt;            myRange.SetRange(myRange.End, myRange.End);&lt;br /&gt;            myRange.InsertParagraphBefore();&lt;br /&gt;            myRange.InsertBefore("Hello world2");&lt;br /&gt;            myRange.InsertParagraphAfter();&lt;br /&gt;            //Remove shading&lt;br /&gt;            myRange.Shading.BackgroundPatternColorIndex = WdColorIndex.wdAuto;&lt;br /&gt;            myRange.Font.Name = "Arial";&lt;br /&gt;            myRange.Font.Size = 14;&lt;br /&gt;            myRange.ParagraphFormat.SpaceAfter = 0;&lt;br /&gt;&lt;br /&gt;            objWordDoc.SaveAs(ref fileName, ref novalue, ref novalue, ref novalue,&lt;br /&gt;            ref novalue, ref novalue, ref novalue, ref novalue, ref novalue,&lt;br /&gt;            ref novalue, ref novalue, ref novalue, ref novalue, ref novalue,&lt;br /&gt;            ref novalue, ref novalue); //Parameters can be different to older Word library's&lt;br /&gt;&lt;br /&gt;            objWord.Quit(ref novalue, ref novalue, ref novalue); &lt;br /&gt;        }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;All the functions in word are available in the library but there's a LOT and i mean really a lot!&lt;br /&gt;&lt;br /&gt;Here are some links which can come handy:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx?MessageChildID=4167&amp;Delete=true"&gt;http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx?MessageChildID=4167&amp;Delete=true&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://support.microsoft.com/kb/316384"&gt;http://support.microsoft.com/kb/316384&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Goodluck creating word documents.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-7686207140489942742?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/7686207140489942742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=7686207140489942742' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/7686207140489942742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/7686207140489942742'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/06/c-creating-ms-word-documents.html' title='C# Creating MS Word documents'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-2787939674673391488</id><published>2008-06-02T13:31:00.004+02:00</published><updated>2008-06-02T13:45:50.551+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='C# ASP.NET'/><title type='text'>How to call a javascript function in serverside code.</title><content type='html'>Today i was looking for a way to close the window in an C# webapplication. This can be done by using window.close(); in javascript. But how to call this from serverside code? So basically the question is how to run javascript from server side code.&lt;br /&gt;&lt;br /&gt;It's really easy:&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;protected void btnUser_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;ClientScript.RegisterStartupScript(GetType(), "close", "window.close();", true);&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;You don't have to use the &amp;lt;script&amp;gt; tags when providing it with the last parameter set to true.&lt;br /&gt;&lt;br /&gt;Apparently this wont work with firefox 2.0 and i cant seem to find a fix for this. For firefox &lt;2.0 you can use the following: &lt;br /&gt;&lt;br /&gt;window.open('','_parent','');&lt;br /&gt;window.close();&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Note:&lt;/em&gt; when using this in Internet Explorer it will ask you to close the window but if you add "window.open('','_parent','');" as above it wont!&lt;br /&gt;&lt;br /&gt;Goodluck.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-2787939674673391488?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/2787939674673391488/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=2787939674673391488' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/2787939674673391488'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/2787939674673391488'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/06/how-to-call-javascript-function-in.html' title='How to call a javascript function in serverside code.'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-8439620343710791797</id><published>2008-05-30T16:31:00.014+02:00</published><updated>2008-05-30T17:45:37.539+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C# ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='GridView'/><title type='text'>Webcontrol GridView with sorting</title><content type='html'>For everyone with the error:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;The GridView "dgGridView" fired event Sorting which wasn't handled.&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;&lt;/span&gt;Here is the solution:&lt;br /&gt;&lt;br /&gt;If you get the above error your allready set the AllowSorting="true" if not set it to your gridView.&lt;br /&gt;Add to the grid an method for the event "sorting", when double click in the properties list it will create a new method for you which looks like this:&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;protected void gvProjectParts_Sorting(object sender, GridViewSortEventArgs e)&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;First we bind the data from SQL and put the datatable in the ViewState because we need this later.&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;if (!IsPostBack)&lt;br /&gt;{&lt;br /&gt;DataSet dataset = new DataSet();&lt;br /&gt;SqlConnection conn = new SqlConnection("ConnectionString");&lt;br /&gt;SqlDataAdapter adapter = new SqlDataAdapter();&lt;br /&gt;adapter.SelectCommand = new SqlCommand("select * from tblTable", conn);&lt;br /&gt;adapter.Fill(dataset);&lt;br /&gt;DataTable table = dataset.Tables[0];&lt;br /&gt;if (table.Rows.Count &gt; 0)&lt;br /&gt;{&lt;br /&gt;gvProjectParts.DataSource = table;&lt;br /&gt;ViewState["gvProjectParts_DataSource"] = table;&lt;br /&gt;gvProjectParts.DataBind();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Then we adjust the sort method where we use the saved viewstate, this is because gvProjectParts.DataSource and send.DataSource are empty:&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;protected void gvProjectParts_Sorting(object sender, GridViewSortEventArgs e)&lt;br /&gt;{&lt;br /&gt;DataTable m_DataTable = (DataTable)ViewState["gvProjectParts_DataSource"];&lt;br /&gt;if (m_DataTable != null)&lt;br /&gt;{&lt;br /&gt;DataView m_DataView = new DataView(m_DataTable);&lt;br /&gt;m_DataView.Sort = e.SortExpression + " " + getSortDirection();&lt;br /&gt;(sender as GridView).DataSource = m_DataView;&lt;br /&gt;(sender as GridView).DataBind();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The function getSortDirection is explained here where we use the ViewState again to store the direction. This is because e.SortDirection is allways ASC.&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;private string getSortDirection()&lt;br /&gt;{&lt;br /&gt;string m_SortDirection;&lt;br /&gt;if (ViewState["gvProjectParts_sortDirection"] == null)&lt;br /&gt;m_SortDirection = "DESC";&lt;br /&gt;else&lt;br /&gt;m_SortDirection = (string)ViewState["gvProjectParts_sortDirection"];&lt;br /&gt;switch (m_SortDirection)&lt;br /&gt;{&lt;br /&gt;case "ASC":&lt;br /&gt;m_SortDirection = "DESC";&lt;br /&gt;break;&lt;br /&gt;case "DESC":&lt;br /&gt;m_SortDirection = "ASC";&lt;br /&gt;break;&lt;br /&gt;}&lt;br /&gt;ViewState["gvProjectParts_sortDirection"] = m_SortDirection;&lt;br /&gt;return m_SortDirection;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Try it out !&lt;br /&gt;&lt;br /&gt;Big thanks to Ryan Olshan and his &lt;a href="http://ryanolshan.com/articles/c-gridview-sorting-paging-w-o-a-datasourcecontrol-datasource/"&gt;post&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;Think it can also be done without using ViewState, please tell me how :)&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;Sjoerd&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-8439620343710791797?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/8439620343710791797/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=8439620343710791797' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/8439620343710791797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/8439620343710791797'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/05/webcontrol-gridview-with-sorting.html' title='Webcontrol GridView with sorting'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-3723172153821266883</id><published>2008-05-26T10:17:00.004+02:00</published><updated>2008-05-26T11:33:50.089+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DIV'/><category scheme='http://www.blogger.com/atom/ns#' term='CSS'/><title type='text'>Rounded Corner Generator</title><content type='html'>I was looking today for a easy way to fix rounded corners on my div. I didnt want to use paint.net for cutting my own corners.&lt;br /&gt;&lt;br /&gt;Following website creates these corners for you including the CSS and DIV code:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.roundedcornr.com/"&gt;http://www.roundedcornr.com/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The following options are available:&lt;br /&gt;&lt;br /&gt;- Basic RoundedCornr&lt;br /&gt;- RoundedCornr with Gradient&lt;br /&gt;- RoundedCornr with Border&lt;br /&gt;- Single RoundedCornr Image ( for buttons ect. )&lt;br /&gt;&lt;br /&gt;The standard weight x height for the RoundedCornr with Border is 1024 x 600. If you want to extend this open the _tl.png image and extend this one to your size.&lt;br /&gt;&lt;br /&gt;Goodluck.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-3723172153821266883?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/3723172153821266883/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=3723172153821266883' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/3723172153821266883'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/3723172153821266883'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/05/rounded-corner-generator.html' title='Rounded Corner Generator'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-4163522090443788709</id><published>2008-05-19T14:54:00.004+02:00</published><updated>2008-05-19T15:15:21.359+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PDF'/><category scheme='http://www.blogger.com/atom/ns#' term='iTextSharp'/><category scheme='http://www.blogger.com/atom/ns#' term='C# ASP.NET'/><title type='text'>iTextSharp table is deprecated use PdfPTable instead</title><content type='html'>I was looking today for the function TableFitsPage, because it wasn't working as i expected it would be. Google turned up with a few results, this was one of them:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://sourceforge.net/mailarchive/message.php?msg_id=003b01c7e0b1%24ad8869a0%246801a8c0%40abraxas.local"&gt;http://sourceforge.net/mailarchive/message.php?msg_id=003b01c7e0b1%24ad8869a0%246801a8c0%40abraxas.local&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This post says: "Use a PdfPTable instead of a Table. Table is not supported anymore"&lt;br /&gt;&lt;br /&gt;I never heard of PdfPTable even in the tutorials the dont mention it. Think they should make it deprecated in the library so people will know it's not supported anymore. Anyways the example from my last article uses the Table class.&lt;br /&gt;&lt;br /&gt;This is the same example but with PdfPTable:&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt; protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            //Create document A4&lt;br /&gt;            Document document = new Document(PageSize.A4);&lt;br /&gt;            //Start the writer&lt;br /&gt;            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("c:\\test.pdf", FileMode.Create));&lt;br /&gt;            //Open the document&lt;br /&gt;            document.Open();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            #region Example2&lt;br /&gt;            //Start table with 2 columns&lt;br /&gt;            //Set the withs for the columns to 10% and 90%&lt;br /&gt;            PdfPTable table = new PdfPTable( new float[] { 10, 90 });&lt;br /&gt;            table.WidthPercentage = 100;            &lt;br /&gt;&lt;br /&gt;            //Add first cell with colspan2&lt;br /&gt;            PdfPCell firstCell = new PdfPCell(new Phrase("Colspan Cell", FontFactory.GetFont(FontFactory.HELVETICA, 14, Color.BLACK)));&lt;br /&gt;            firstCell.Colspan = 2;&lt;br /&gt;            firstCell.VerticalAlignment = Element.ALIGN_TOP;&lt;br /&gt;            firstCell.BorderWidthBottom = 0.5f;&lt;br /&gt;            table.AddCell(firstCell);&lt;br /&gt;&lt;br /&gt;            //Add more cells&lt;br /&gt;            for (int i = 0; i &lt; 10; i++)&lt;br /&gt;            {&lt;br /&gt;                PdfPCell moreCells = new PdfPCell(new Phrase("Cell " + i.ToString(), FontFactory.GetFont(FontFactory.HELVETICA_OBLIQUE, 12)));&lt;br /&gt;                moreCells.VerticalAlignment = Element.ALIGN_TOP;&lt;br /&gt;                moreCells.Colspan = 1;&lt;br /&gt;                moreCells.BorderWidth = 0.5f;&lt;br /&gt;                table.AddCell(moreCells);&lt;br /&gt;            }&lt;br /&gt;            //Add table to document&lt;br /&gt;            document.Add(table);&lt;br /&gt;            #endregion&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            //Close the document&lt;br /&gt;            document.Close();&lt;br /&gt;        }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Cell -&gt; PdfPCell&lt;br /&gt;Chunk -&gt; Phrase&lt;br /&gt;Table - &gt; PdfPTable&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Goodluck.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-4163522090443788709?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/4163522090443788709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=4163522090443788709' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/4163522090443788709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/4163522090443788709'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/05/itextsharp-table-is-deprecated-use.html' title='iTextSharp table is deprecated use PdfPTable instead'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-453610148433121690</id><published>2008-05-18T15:42:00.006+02:00</published><updated>2008-05-18T16:41:43.909+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PDF'/><category scheme='http://www.blogger.com/atom/ns#' term='MemoryStream'/><category scheme='http://www.blogger.com/atom/ns#' term='iTextSharp'/><category scheme='http://www.blogger.com/atom/ns#' term='C# ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Mail'/><title type='text'>Create PDF files in memory and mail them as an attachment</title><content type='html'>In my previous post i showed how to create an PDF file on-the-fly with iTextSharp.&lt;br /&gt;&lt;br /&gt;Now we pick up the first HELLO WORLD example and dont write it to C:\text.pdf but to a MemoryStream. After that we mail it as an attachment.&lt;br /&gt;&lt;br /&gt;As you will see it's no rocket science!&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;&lt;br /&gt;        protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            //Create document A4&lt;br /&gt;            Document document = new Document(PageSize.A4);&lt;br /&gt;            //Start the writer and write to memory&lt;br /&gt;            MemoryStream myStream = new MemoryStream();&lt;br /&gt;            PdfWriter writer = PdfWriter.GetInstance(document, myStream);&lt;br /&gt;            //Open document&lt;br /&gt;            document.Open();&lt;br /&gt;&lt;br /&gt;            #region Example1&lt;br /&gt;            //Set some document attributes&lt;br /&gt;            document.AddTitle("Hello world");&lt;br /&gt;            document.AddAuthor("Sjoerd Perfors");&lt;br /&gt;            document.AddSubject("This is my first PDF created on: " + DateTime.Now.ToShortDateString());&lt;br /&gt;            //Add an image&lt;br /&gt;            iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance("c:\\caesar_coin.jpg");&lt;br /&gt;            document.Add(image);&lt;br /&gt;            //Add a normal text&lt;br /&gt;            document.Add(new Chunk("HELLO WORLD", FontFactory.GetFont(FontFactory.HELVETICA, 18, Color.RED)));&lt;br /&gt;            //Add text to a specific position&lt;br /&gt;            PdfContentByte cb = writer.DirectContent;&lt;br /&gt;            BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);&lt;br /&gt;            cb.BeginText();&lt;br /&gt;            cb.SetFontAndSize(bf, 12);&lt;br /&gt;            cb.ShowTextAligned(Element.ALIGN_RIGHT, "Another text placed on 100,400", 100, 400, 0);&lt;br /&gt;            cb.EndText();&lt;br /&gt;            #endregion&lt;br /&gt;&lt;br /&gt;            //Close the document&lt;br /&gt;            document.Close();&lt;br /&gt;&lt;br /&gt;            //Copy the stream to another stream and close it.&lt;br /&gt;            MemoryStream pdfstream = new MemoryStream(myStream.ToArray());&lt;br /&gt;            myStream.Close();&lt;br /&gt;            //Use the stream to send email&lt;br /&gt;            string fromEmail = "someone@someplace.com";&lt;br /&gt;            string toEmail = "someone@thisplace.com";&lt;br /&gt;            string body = "BODY";&lt;br /&gt;            string titel = "Sending your personal on the fly created PDF!!";&lt;br /&gt;           &lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                //Create the mailmessage object.&lt;br /&gt;                MailMessage objEmail = new MailMessage(fromEmail, toEmail, titel, body);&lt;br /&gt;                //Add the stream as attachemnt.&lt;br /&gt;                objEmail.Attachments.Add(new Attachment(pdfstream, "yourpdf.pdf"));&lt;br /&gt;                //Create the smtpclient with a SMTPserver defined in your web.config.&lt;br /&gt;                SmtpClient emailClient = new SmtpClient(ConfigurationManager.AppSettings["SMTPServer"]);&lt;br /&gt;                //Send the mail&lt;br /&gt;                emailClient.Send(objEmail);&lt;br /&gt;                //Close the stream&lt;br /&gt;                pdfstream.Close();&lt;br /&gt;            }&lt;br /&gt;            catch (Exception exc)&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine("Send failure: " + exc.ToString());&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Goodluck!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-453610148433121690?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/453610148433121690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=453610148433121690' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/453610148433121690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/453610148433121690'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/05/create-pdf-files-in-memory-and-mail.html' title='Create PDF files in memory and mail them as an attachment'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-2886375389186102533</id><published>2008-05-18T14:21:00.016+02:00</published><updated>2008-05-19T15:16:21.786+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PDF'/><category scheme='http://www.blogger.com/atom/ns#' term='iTextSharp'/><category scheme='http://www.blogger.com/atom/ns#' term='C# ASP.NET'/><title type='text'>How to create on-the-fly FREE PDF files in C# Asp.net with tables/images/page numbering and more!</title><content type='html'>Hi there, been a while since my last post..&lt;br /&gt;&lt;br /&gt;Today i will show how to create "on the fly" PDF files. I used this for an web application where users have a "personal" PDF file in their mailbox.&lt;br /&gt;&lt;br /&gt;There are many library's available for creating PDF files. This site will show a list of open source library's: &lt;a href="http://csharp-source.net/open-source/pdf-libraries"&gt;csharp-source.net/open-source/pdf-libraries&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Some of them i have tried:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://report.sourceforge.net"&gt;Report.NET&lt;/a&gt;&lt;br /&gt;&lt;a href="http://sharppdf.sourceforge.net/"&gt;SharpPDF&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.pdfsharp.com"&gt;PDFsharp&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;but i think the easiest to use is &lt;strong&gt;iTextSharp&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;The homepage of iTextSharp is: &lt;a href="http://sourceforge.net/projects/itextsharp/"&gt;http://sourceforge.net/projects/itextsharp/&lt;/a&gt; Here you can download the library, source code and examples.&lt;br /&gt;&lt;br /&gt;Short description from the iTextSharp homepage:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;"iText# (iTextSharp) is a port of the iText open source java library written entirely in C# for the .NET platform. iText# is a library that allows you to generate PDF files on the fly. It is implemented as an assembly."&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;The example project creates a large amount of PDF files to show what can be done with iTextSharp. You will have to comment a lot in order to get it working but after that it can come handy. This is because the examples project was build on an earlier version of iTextSharp.&lt;br /&gt;&lt;br /&gt;Here are some tutorials for iTextSharp:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://itextsharp.sourceforge.net/tutorial/index.html"&gt;itextsharp.sourceforge.net/tutorial/index.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.aspfree.com/c/a/BrainDump/Working-with-iTextSharp/"&gt;www.aspfree.com/c/a/BrainDump/Working-with-iTextSharp/&lt;/a&gt; ( found this while writing this article )&lt;br /&gt;&lt;br /&gt;OK lets start Visual studio!&lt;br /&gt;&lt;br /&gt;First we need to add a reference to the iTextSharp library:&lt;br /&gt;&lt;br /&gt;references -&gt; add reference -&gt; browse -&gt; select itextsharp.dll&lt;br /&gt;&lt;br /&gt;Then we can include the following to our class:&lt;br /&gt;&lt;br /&gt;using iTextSharp.text.pdf;&lt;br /&gt;using iTextSharp.text;&lt;br /&gt;&lt;br /&gt;and for file access:&lt;br /&gt;&lt;br /&gt;using System.IO;&lt;br /&gt;&lt;br /&gt;First we write the hello world with an image and some texts:&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;//Create document A4&lt;br /&gt;Document document = new Document(PageSize.A4);&lt;br /&gt;//Start the writer&lt;br /&gt;PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("c:\\test.pdf", FileMode.Create));&lt;br /&gt;//Open the document&lt;br /&gt;document.Open();&lt;br /&gt;//Set some document attributes&lt;br /&gt;document.AddTitle("Hello world");&lt;br /&gt;document.AddAuthor("Sjoerd Perfors");&lt;br /&gt;document.AddSubject("This is my first PDF created on: " + DateTime.Now.ToShortDateString());&lt;br /&gt;//Add an image&lt;br /&gt;iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance("c:\\caesar_coin.jpg");&lt;br /&gt;document.Add(image);&lt;br /&gt;//Add a normal text&lt;br /&gt;document.Add(new Chunk("HELLO WORLD", FontFactory.GetFont(FontFactory.HELVETICA, 18, Color.RED)));&lt;br /&gt;//Add text to a specific position&lt;br /&gt;PdfContentByte cb = writer.DirectContent;&lt;br /&gt;BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);&lt;br /&gt;cb.BeginText();&lt;br /&gt;cb.SetFontAndSize(bf, 12);&lt;br /&gt;cb.ShowTextAligned(Element.ALIGN_RIGHT, "Another text placed on 100,400", 100, 400, 0);&lt;br /&gt;cb.EndText();&lt;br /&gt;//Close the document&lt;br /&gt;document.Close();&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;See how easy it is?&lt;br /&gt;&lt;br /&gt;Remember that the X and Y positions are calculated from the bottomleft and not from the topleft.&lt;br /&gt;&lt;br /&gt;The following example shows how to create an table with 2 columns&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;&lt;strong&gt;TABLE IS DEPRECATED SEE &lt;a href="http://sdheadaches.blogspot.com/2008/05/itextsharp-table-is-deprecated-use.html"&gt;MY NEW POST &lt;/a&gt;WITH A EXAMPLE USING PdfPTable&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;#region Example2&lt;br /&gt;//Start table with 2 columns&lt;br /&gt;iTextSharp.text.Table table = new iTextSharp.text.Table(2);&lt;br /&gt;table.BorderWidth = 0;&lt;br /&gt;table.Padding = 2;&lt;br /&gt;//Set the withs for the columns to 10% and 90%&lt;br /&gt;float[] headerwidths = { 10, 90 };&lt;br /&gt;table.Widths = headerwidths;&lt;br /&gt;table.Width = 100;&lt;br /&gt;&lt;br /&gt;//Add first cell with colspan2&lt;br /&gt;Cell firstCell = new Cell(new Chunk("Colspan Cell", FontFactory.GetFont(FontFactory.HELVETICA, 14, Color.BLACK)));&lt;br /&gt;firstCell.Colspan = 2;&lt;br /&gt;firstCell.VerticalAlignment = Element.ALIGN_TOP;&lt;br /&gt;firstCell.BorderWidthBottom = 0.5f;&lt;br /&gt;table.AddCell(firstCell);&lt;br /&gt;&lt;br /&gt;//Add more cells&lt;br /&gt;for (int i = 0; i &lt; 10; i++)&lt;br /&gt;{&lt;br /&gt;Cell moreCells = new Cell(new Chunk("Cell "+ i.ToString() , FontFactory.GetFont(FontFactory.HELVETICA_OBLIQUE,12)));&lt;br /&gt;moreCells.VerticalAlignment = Element.ALIGN_TOP;&lt;br /&gt;moreCells.Colspan = 1;&lt;br /&gt;moreCells.BorderWidth = 0.5f;&lt;br /&gt;table.AddCell(moreCells);&lt;br /&gt;}&lt;br /&gt;//Add table to document&lt;br /&gt;document.Add(table);&lt;br /&gt;#endregion&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;To add some nice functions like page numbering or footers we have to create a new class which extends the class PdfPageEventHelper. This class has the following handy functions:&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;public virtual void OnChapter(PdfWriter writer, Document document, float paragraphPosition, Paragraph title);&lt;br /&gt;public virtual void OnChapterEnd(PdfWriter writer, Document document, float position);&lt;br /&gt;public virtual void OnCloseDocument(PdfWriter writer, Document document);&lt;br /&gt;public virtual void OnEndPage(PdfWriter writer, Document document);&lt;br /&gt;public virtual void OnGenericTag(PdfWriter writer, Document document, Rectangle rect, string text);&lt;br /&gt;public virtual void OnOpenDocument(PdfWriter writer, Document document);&lt;br /&gt;public virtual void OnParagraph(PdfWriter writer, Document document, float paragraphPosition);&lt;br /&gt;public virtual void OnParagraphEnd(PdfWriter writer, Document document, float paragraphPosition);&lt;br /&gt;public virtual void OnSection(PdfWriter writer, Document document, float paragraphPosition, int depth, Paragraph title);&lt;br /&gt;public virtual void OnSectionEnd(PdfWriter writer, Document document, float position);&lt;br /&gt;public virtual void OnStartPage(PdfWriter writer, Document document);&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;To use the functions we create a new class and overides above functions with out own code to create a nice footer:&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;public class PDFPageEvents: PdfPageEventHelper&lt;br /&gt;{&lt;br /&gt;PdfPTable table;&lt;br /&gt;PdfTemplate tpl;&lt;br /&gt;BaseFont helv;&lt;br /&gt;&lt;br /&gt;public override void OnOpenDocument(PdfWriter writer, Document document)&lt;br /&gt;{&lt;br /&gt;table = new PdfPTable(2);&lt;br /&gt;// initialization of the template&lt;br /&gt;tpl = writer.DirectContent.CreateTemplate(100, 100);&lt;br /&gt;tpl.BoundingBox = new Rectangle(-20, -20, 100, 100);&lt;br /&gt;// initialization of the font&lt;br /&gt;helv = BaseFont.CreateFont("Helvetica", BaseFont.WINANSI, false);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public override void OnEndPage(PdfWriter writer, Document document)&lt;br /&gt;{&lt;br /&gt;if (document.PageNumber == 1)&lt;br /&gt;return;&lt;br /&gt;PdfContentByte cb = writer.DirectContent;&lt;br /&gt;cb.SaveState();&lt;br /&gt;// write the headertable&lt;br /&gt;float[] floatwidth = { (document.Right - document.Left) };&lt;br /&gt;table.TotalWidth = 100;&lt;br /&gt;//table.SetTotalWidth(floatwidth);&lt;br /&gt;table.WriteSelectedRows(0, -1, document.Left, document.PageSize.Height - 50, cb);&lt;br /&gt;// compose the footer&lt;br /&gt;String text = "Page " + writer.PageNumber + " of ";&lt;br /&gt;&lt;br /&gt;float textSize = helv.GetWidthPoint(text, 12);&lt;br /&gt;float textBase = document.Bottom - 20;&lt;br /&gt;cb.BeginText();&lt;br /&gt;cb.SetFontAndSize(helv, 12);&lt;br /&gt;&lt;br /&gt;float adjust = helv.GetWidthPoint("0", 12);&lt;br /&gt;cb.SetTextMatrix(document.Right - textSize - adjust, textBase);&lt;br /&gt;cb.ShowText(text);&lt;br /&gt;cb.EndText();&lt;br /&gt;&lt;br /&gt;cb.AddTemplate(tpl, document.Right - adjust, textBase);&lt;br /&gt;&lt;br /&gt;cb.SaveState();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public override void OnCloseDocument(PdfWriter writer, Document document)&lt;br /&gt;{&lt;br /&gt;tpl.BeginText();&lt;br /&gt;tpl.SetFontAndSize(helv, 12);&lt;br /&gt;tpl.SetTextMatrix(0, 0);&lt;br /&gt;tpl.ShowText("" + (writer.PageNumber - 1));&lt;br /&gt;tpl.EndText();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now in our previous example we add the following:&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;//Create document A4&lt;br /&gt;Document document = new Document(PageSize.A4);&lt;br /&gt;//Start the writer&lt;br /&gt;PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("c:\\test.pdf", FileMode.Create));&lt;br /&gt;PDFPageEvents pageEvent = new PDFPageEvents();&lt;br /&gt;writer.PageEvent = pageEvent;&lt;br /&gt;//Open the document&lt;br /&gt;document.Open();&lt;br /&gt;document.Add(new Chunk("This is a new page WITHOUT page numbering."));&lt;br /&gt;document.NewPage();&lt;br /&gt;for (int i = 0; i &lt; 5; i++)&lt;br /&gt;{&lt;br /&gt;document.Add(new Chunk("This is a new page WITH page numbering."));&lt;br /&gt;document.NewPage();&lt;br /&gt;}&lt;br /&gt;//Close the document&lt;br /&gt;document.Close();&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;In the next article i will descripe how to create an PDF in memory and mail this as an attachment.&lt;br /&gt;&lt;br /&gt;Goodluck and big thanks for iTextSharp!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-2886375389186102533?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/2886375389186102533/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=2886375389186102533' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/2886375389186102533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/2886375389186102533'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/05/how-to-create-on-fly-free-pdf-files-in.html' title='How to create on-the-fly FREE PDF files in C# Asp.net with tables/images/page numbering and more!'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-1446694340839601187</id><published>2008-04-18T09:34:00.008+02:00</published><updated>2008-05-18T15:41:25.817+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MD5'/><category scheme='http://www.blogger.com/atom/ns#' term='C# ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Password'/><category scheme='http://www.blogger.com/atom/ns#' term='Random'/><category scheme='http://www.blogger.com/atom/ns#' term='Encrypt'/><title type='text'>C# MD5 Encrypt and Random password generator</title><content type='html'>I think these functions can come handy for anyone who is developing C# webpages.&lt;br /&gt;&lt;br /&gt;First function generates an random password with the given length:&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;public string GetRandomPasswordUsingGUID(int length)&lt;br /&gt;{&lt;br /&gt;// Get the GUID&lt;br /&gt;string guidResult = System.Guid.NewGuid().ToString();&lt;br /&gt;// Remove the hyphens&lt;br /&gt;guidResult = guidResult.Replace("-", string.Empty);&lt;br /&gt;// Make sure length is valid&lt;br /&gt;if (length &lt;= 0  length &gt; guidResult.Length)&lt;br /&gt;throw new ArgumentException("Length must be between 1 and " + guidResult.Length);&lt;br /&gt;// Return the first length bytes&lt;br /&gt;return guidResult.Substring(0, length);&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Second function Encodes the given string to an MD5 string.&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;public string EncodePassword(string originalPassword)&lt;br /&gt;{&lt;br /&gt;//Declarations&lt;br /&gt;Byte[] originalBytes;&lt;br /&gt;Byte[] encodedBytes;&lt;br /&gt;MD5 md5;&lt;br /&gt;//Instantiate MD5CryptoServiceProvider, get bytes for original password and compute hash (encoded password)&lt;br /&gt;md5 = new MD5CryptoServiceProvider();&lt;br /&gt;originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword);&lt;br /&gt;encodedBytes = md5.ComputeHash(originalBytes);&lt;br /&gt;//Convert encoded bytes back to a 'readable' string&lt;br /&gt;return BitConverter.ToString(encodedBytes);&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Last function i ripped of an other site, im not sure which one it was. Credits for him/her :-)&lt;br /&gt;&lt;br /&gt;Goodluck,&lt;br /&gt;Sjoerd&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-1446694340839601187?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/1446694340839601187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=1446694340839601187' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/1446694340839601187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/1446694340839601187'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/04/c-md5-encrypt-and-random-password.html' title='C# MD5 Encrypt and Random password generator'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-712398359818980824</id><published>2008-04-17T17:03:00.008+02:00</published><updated>2008-05-18T15:41:11.687+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C# ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='.resources'/><category scheme='http://www.blogger.com/atom/ns#' term='.resx'/><title type='text'>Compile .resx to .resources files from .NET 1.0 projects.</title><content type='html'>I found out today that old .&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;resx&lt;/span&gt; files from .Net 1.0 projects wont compile &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_1"&gt;automatically&lt;/span&gt;. You have to do this by your self after a change in it!&lt;br /&gt;&lt;br /&gt;resgen.exe will do this for you. This little program is somewhere in your visual studio folder:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;resgen.exe test.resx test.resources&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This will compile the resx file to a binairy resources file.&lt;br /&gt;&lt;br /&gt;You can add this to your tools in Visual Studio (i used 2005). So you dont need to open an command prompt window each time:&lt;br /&gt;&lt;br /&gt;Tools -&gt; External Tools -&gt; Add -&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Title:&lt;/span&gt;&lt;span style="color:#3366ff;"&gt; Build .resource file&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Command: &lt;/span&gt;&lt;span style="color:#3366ff;"&gt;C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SDKTools\resgen.exe&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Arguments: &lt;/span&gt;&lt;span style="color:#3366ff;"&gt;$(ItemPath)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;Initial directory: &lt;/span&gt;&lt;span style="color:#3366ff;"&gt;$(ItemDir)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;&lt;span style="color:#3333ff;"&gt;[v]&lt;/span&gt; use output window&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This will compile the current opend resx file to a resource file in the same directory.&lt;br /&gt;&lt;br /&gt;Here's my output:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;Read in 150 resources from 'D:\Projecten\***\TextRes-EN.resx'&lt;br /&gt;Writing resource file... Done.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Goodluck!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-712398359818980824?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/712398359818980824/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=712398359818980824' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/712398359818980824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/712398359818980824'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/04/compile-resx-to-resources-files-from.html' title='Compile .resx to .resources files from .NET 1.0 projects.'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-4544593940976572552</id><published>2008-04-17T16:17:00.005+02:00</published><updated>2008-05-18T15:40:56.240+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C# ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='AppSettings'/><category scheme='http://www.blogger.com/atom/ns#' term='ConfigurationManager'/><category scheme='http://www.blogger.com/atom/ns#' term='ConfigurationSettings'/><title type='text'>C# System.Configuration.ConfigurationSettings.AppSettings is obsolete !</title><content type='html'>&lt;p&gt;Today, when i was building an old project, i got the following warning:&lt;/p&gt;&lt;span style="color:#ff0000;"&gt;Warning 10 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;With the following line of code:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;SmtpClient emailClient = new SmtpClient(ConfigurationSettings.AppSettings["SMTPServer"]);&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Oke so just replace it right? ..Not working:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;SmtpClient emailClient = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["SMTPServer"]);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;ConfigurationManager not found...&lt;br /&gt;&lt;br /&gt;The thing is they packed the ConfigurationManager in another dll file, which you need to add as reference.&lt;br /&gt;&lt;br /&gt;right-click References -&gt; add reference -&gt; select System.Configuration in .NET tab&lt;br /&gt;&lt;br /&gt;Et voila following code works:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3366ff;"&gt;SmtpClient emailClient = new SmtpClient(ConfigurationManager.AppSettings["SMTPServer"]);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Hope this will help anyone.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-4544593940976572552?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/4544593940976572552/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=4544593940976572552' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/4544593940976572552'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/4544593940976572552'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/04/c-systemconfigurationconfigurationsetti.html' title='C# System.Configuration.ConfigurationSettings.AppSettings is obsolete !'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-6887746662206526203</id><published>2008-04-01T16:17:00.006+02:00</published><updated>2008-05-18T15:40:29.165+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='UUencode'/><category scheme='http://www.blogger.com/atom/ns#' term='C# ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='UUdecode'/><title type='text'>UUencode and UUdecode in C#.net</title><content type='html'>I was looking today for a new UUencode function and my colleague ended up with the following class which works like a charm. This one is really fast.&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Text;&lt;br /&gt;public static class Codecs&lt;br /&gt;{&lt;br /&gt;static&lt;br /&gt;readonly byte[] UUEncMap = new byte[]&lt;br /&gt;{&lt;br /&gt;0x60, 0x21, 0x22, 0x23, 0x24,&lt;br /&gt;0x25, 0x26, 0x27,&lt;br /&gt;0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,&lt;br /&gt;0x30,&lt;br /&gt;0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,&lt;br /&gt;0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D,&lt;br /&gt;0x3E, 0x3F,&lt;br /&gt;0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,&lt;br /&gt;0x48, 0x49,&lt;br /&gt;0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,&lt;br /&gt;0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,&lt;br /&gt;0x57,&lt;br /&gt;0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F&lt;br /&gt;};&lt;br /&gt;static readonly&lt;br /&gt;byte[] UUDecMap = new byte[]&lt;br /&gt;{&lt;br /&gt;0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,&lt;br /&gt;0x00,&lt;br /&gt;0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,&lt;br /&gt;0x00, 0x00, 0x00,&lt;br /&gt;0x00, 0x00, 0x00, 0x00, 0x00,&lt;br /&gt;0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,&lt;br /&gt;0x00,&lt;br /&gt;0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,&lt;br /&gt;0x08, 0x09, 0x0A,&lt;br /&gt;0x0B, 0x0C, 0x0D, 0x0E, 0x0F,&lt;br /&gt;0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,&lt;br /&gt;0x17,&lt;br /&gt;0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,&lt;br /&gt;0x20, 0x21, 0x22,&lt;br /&gt;0x23, 0x24, 0x25, 0x26, 0x27,&lt;br /&gt;0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E,&lt;br /&gt;0x2F,&lt;br /&gt;0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,&lt;br /&gt;0x38, 0x39, 0x3A,&lt;br /&gt;0x3B, 0x3C, 0x3D, 0x3E, 0x3F,&lt;br /&gt;0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,&lt;br /&gt;0x00,&lt;br /&gt;0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,&lt;br /&gt;0x00, 0x00, 0x00,&lt;br /&gt;0x00, 0x00, 0x00, 0x00, 0x00,&lt;br /&gt;0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,&lt;br /&gt;0x00&lt;br /&gt;};&lt;br /&gt;public static void UUDecode(System.IO.Stream input,&lt;br /&gt;System.IO.Stream output)&lt;br /&gt;{&lt;br /&gt;//if (input == null)&lt;br /&gt;// throw new&lt;br /&gt;ArgumentNullException("input");&lt;br /&gt;//if (output == null)&lt;br /&gt;// throw new&lt;br /&gt;ArgumentNullException("output");&lt;br /&gt;long len = input.Length;&lt;br /&gt;if (len ==&lt;br /&gt;0)&lt;br /&gt;return;&lt;br /&gt;long didx = 0;&lt;br /&gt;int nextByte = input.ReadByte();&lt;br /&gt;while&lt;br /&gt;(nextByte &gt;= 0)&lt;br /&gt;{&lt;br /&gt;// get line length (in number of encoded&lt;br /&gt;octets)&lt;br /&gt;int line_len = UUDecMap[nextByte];&lt;br /&gt;// ascii printable to 0-63 and&lt;br /&gt;4-byte to 3-byte conversion&lt;br /&gt;long end = didx + line_len;&lt;br /&gt;byte A, B, C,&lt;br /&gt;D;&lt;br /&gt;if (end &gt; 2)&lt;br /&gt;{&lt;br /&gt;while (didx &lt; a =" UUDecMap[input.ReadByte()];" b =" UUDecMap[input.ReadByte()];" c =" UUDecMap[input.ReadByte()];" d =" UUDecMap[input.ReadByte()];"&gt;&gt; 4) &amp;amp; 3)));&lt;br /&gt;output.WriteByte((byte)(((B &lt;&lt;&gt;&gt; 2) &amp;amp; 15)));&lt;br /&gt;output.WriteByte((byte)(((C&lt;br /&gt;&lt;&lt; a =" UUDecMap[input.ReadByte()];" b =" UUDecMap[input.ReadByte()];"&gt;&gt; 4) &amp;amp; 3)));&lt;br /&gt;didx++;&lt;br /&gt;}&lt;br /&gt;if (didx &lt; b =" UUDecMap[input.ReadByte()];" c =" UUDecMap[input.ReadByte()];"&gt;&gt; 2) &amp;amp; 15)));&lt;br /&gt;didx++;&lt;br /&gt;}&lt;br /&gt;// skip&lt;br /&gt;padding&lt;br /&gt;do&lt;br /&gt;{&lt;br /&gt;nextByte = input.ReadByte();&lt;br /&gt;}&lt;br /&gt;while (nextByte &gt;=&lt;br /&gt;0 &amp;amp;&amp;amp; nextByte != '\n' &amp;amp;&amp;amp; nextByte != '\r');&lt;br /&gt;// skip end of&lt;br /&gt;line&lt;br /&gt;do&lt;br /&gt;{&lt;br /&gt;nextByte = input.ReadByte();&lt;br /&gt;}&lt;br /&gt;while (nextByte &gt;= 0&lt;br /&gt;&amp;amp;&amp;amp; (nextByte == '\n' nextByte == '\r'));&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;public static&lt;br /&gt;void UUEncode(System.IO.Stream input, System.IO.Stream output)&lt;br /&gt;{&lt;br /&gt;//if&lt;br /&gt;(input == null)&lt;br /&gt;// throw new ArgumentNullException("input");&lt;br /&gt;//if (output&lt;br /&gt;== null)&lt;br /&gt;// throw new ArgumentNullException("output");&lt;br /&gt;long len =&lt;br /&gt;input.Length;&lt;br /&gt;if (len == 0)&lt;br /&gt;return;&lt;br /&gt;int sidx = 0;&lt;br /&gt;int line_len =&lt;br /&gt;45;&lt;br /&gt;byte[] nl = Encoding.ASCII.GetBytes(Environment.NewLine);&lt;br /&gt;byte A, B,&lt;br /&gt;C;&lt;br /&gt;// split into lines, adding line-length and line terminator&lt;br /&gt;while (sidx&lt;br /&gt;+ line_len &lt; end =" sidx" a =" (byte)input.ReadByte();" b =" (byte)input.ReadByte();" c =" (byte)input.ReadByte();"&gt;&gt; 2) &amp;amp;&lt;br /&gt;63]);&lt;br /&gt;output.WriteByte(UUEncMap[(B &gt;&gt; 4) &amp;amp; 15 (A &lt;&lt;&gt;&gt; 6) &amp;amp; 3 (B &lt;&lt; idx =" 0;" a =" (byte)input.ReadByte();" b =" (byte)input.ReadByte();" c =" (byte)input.ReadByte();"&gt;&gt; 2) &amp;amp;&lt;br /&gt;63]);&lt;br /&gt;output.WriteByte(UUEncMap[(B &gt;&gt; 4) &amp;amp; 15 (A &lt;&lt;&gt;&gt; 6) &amp;amp; 3 (B &lt;&lt; a =" (byte)input.ReadByte();" b =" (byte)input.ReadByte();"&gt;&gt; 2) &amp;amp;&lt;br /&gt;63]);&lt;br /&gt;output.WriteByte(UUEncMap[(B &gt;&gt; 4) &amp;amp; 15 (A &lt;&lt; a =" (byte)input.ReadByte();"&gt;&gt; 2) &amp;amp; 63]);&lt;br /&gt;output.WriteByte(UUEncMap[(A &lt;&lt; idx =" 0;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;I call my function like this:&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;//First write to memory&lt;br /&gt;MemoryStream&lt;br /&gt;mmsStream = new MemoryStream();&lt;br /&gt;StreamWriter srwTemp = new&lt;br /&gt;StreamWriter(mmsStream);&lt;br /&gt;//sBuffer is my encoded&lt;br /&gt;text.&lt;br /&gt;srwTemp.Write(sBuffer);&lt;br /&gt;srwTemp.Flush();&lt;br /&gt;mmsStream.Position =&lt;br /&gt;0;&lt;br /&gt;//Write to IO..filename is a localvar which&lt;br /&gt;has the location of the file.&lt;br /&gt;System.IO.FileStream stmStreamOut = new&lt;br /&gt;System.IO.FileStream(filename, FileMode.OpenOrCreate);&lt;br /&gt;//Calling&lt;br /&gt;UUDecode&lt;br /&gt;Codecs.UUDecode(mmsStream,&lt;br /&gt;stmStreamOut);&lt;br /&gt;stmStreamOut.Flush();&lt;br /&gt;stmStreamOut.Close();&lt;br /&gt;//Done&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Goodluck.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-6887746662206526203?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/6887746662206526203/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=6887746662206526203' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/6887746662206526203'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/6887746662206526203'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/04/uuencode-and-uudecode-in-cnet.html' title='UUencode and UUdecode in C#.net'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-2239999091690201978</id><published>2008-03-28T16:01:00.034+01:00</published><updated>2008-04-08T12:48:08.704+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wrapper'/><category scheme='http://www.blogger.com/atom/ns#' term='flex'/><category scheme='http://www.blogger.com/atom/ns#' term='charts'/><category scheme='http://www.blogger.com/atom/ns#' term='actionscript'/><category scheme='http://www.blogger.com/atom/ns#' term='flash'/><title type='text'>Using Flash Charts in a Flex3 Application</title><content type='html'>&lt;span style="color:#ff0000;"&gt;If you're looking for Chart components to work with Flex applications: &lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;- ILOG Elixir (Flex charts) &lt;a href="http://www.ilog.com/products/elixir/"&gt;http://www.ilog.com/products/elixir/&lt;/a&gt;&lt;br /&gt;- Fusioncharts (Flash) is producing in a couple weeks support for Flex. &lt;a href="http://www.fusioncharts.com/"&gt;http://www.fusioncharts.com/&lt;/a&gt;&lt;br /&gt;- Anycharts (Flash) &lt;/span&gt;&lt;a href="http://www.anychart.com/blog/category/anychart-for-flex/"&gt;&lt;span style="color:#ff0000;"&gt;http://www.anychart.com/blog/category/anychart-for-flex/&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In this post i will try to create a wrapper for flash charts. This can also be handy when you're in a need of any Flash AS2 Components. I have seen some people doing it ( or saying they did it ) so it wouldn't be any problem...right?&lt;br /&gt;&lt;br /&gt;Google brought me the following results which can be handy:&lt;br /&gt;&lt;br /&gt;1 &lt;a href="http://flexexamples.blogspot.com/2007/12/load-swf-from-outside-and-call-its.html"&gt;http://flexexamples.blogspot.com/2007/12/load-swf-from-outside-and-call-its.html&lt;/a&gt;&lt;br /&gt;2 &lt;a href="http://wiki.apexdevnet.com/index.php/Creating_Flex_Charts_Easily"&gt;http://wiki.apexdevnet.com/index.php/Creating_Flex_Charts_Easily&lt;/a&gt;&lt;br /&gt;3 &lt;a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=749eaa47&amp;amp;sliceId=1"&gt;http://kb.adobe.com/selfservice/viewContent.do?externalId=749eaa47&amp;amp;sliceId=1&lt;/a&gt;&lt;br /&gt;4 &lt;a href="http://www.fusioncharts.com/forum/Topic5068-28-1.aspx"&gt;http://www.fusioncharts.com/forum/Topic5068-28-1.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Since these flashcharts all use ActionScript 2.0 they cant really communicate with Flex2/3 which uses AS 3.0. If i build an AS2.0 Wrapper Flash that communicates trough localconnection with my flex application and also communicates with the chart object then it should work.&lt;br /&gt;&lt;br /&gt;First i will use the FusionCharts ( &lt;a href="http://www.blogger.com/www.fusioncharts.com/LiveDemos.asp"&gt;http://www.blogger.com/www.fusioncharts.com/LiveDemos.asp&lt;/a&gt; ) ( since most examples use them ) then i will try the amCharts ( &lt;a href="http://www.amcharts.com/"&gt;www.amcharts.com/&lt;/a&gt; ).&lt;br /&gt;&lt;br /&gt;Here's what i want to do:&lt;br /&gt;&lt;br /&gt;- Create a wrapper flash object to communicate between Flex and the Flash chart&lt;br /&gt;- Setup a link in Flex to use the Wrapped Flash object.&lt;br /&gt;- Building a chart with XML data from Flex&lt;br /&gt;- Doing the same with amCharts&lt;br /&gt;&lt;br /&gt;First i need to install Flash CS3 to create the wrapper, but then i never used Flash CS3..&lt;br /&gt;&lt;br /&gt;Following code is for my wrapper class and will change the text:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;//local Connection with flex&lt;br /&gt;var flash_flex:LocalConnection = new&lt;br /&gt;LocalConnection();&lt;br /&gt;//here connection can be made inter-domain&lt;br /&gt;flash_flex.allowDomain("*");&lt;br /&gt;flash_flex.connect("flex_connector");&lt;br /&gt;flash_flex.allowInsecureDomain("*");&lt;br /&gt;flash_flex.changeText =&lt;br /&gt;function(test : String):Void&lt;br /&gt;{&lt;br /&gt;TEXTBOX.text = test;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;In flash:&lt;br /&gt;- choose to create a new flash file with AS2.0&lt;br /&gt;- create an text object on the screen&lt;br /&gt;- Change the instance name to TEXTBOX&lt;br /&gt;- Change to dynamic text&lt;br /&gt;- Right click on the timeframe and choose for "Actions"&lt;br /&gt;- A code like editor comes up, paste the code above on it and close it.&lt;br /&gt;- Export this using Flash7 and AS2.0 to an SWF file and call it WRAPPER.swf&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now in flex create an localconnection and call the function with one parameter:&lt;br /&gt;&lt;br /&gt;MXML&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;mx:SWFLoader source="WRAPPER.swf" scaleContent="true" width="300" height="300" x="10" y="10"&amp;gt;&amp;lt;/mx:SWFLoader&amp;gt;&lt;br /&gt;&amp;lt;mx:Button x="374" y="57" label="Button" click="click();"&amp;gt;&amp;lt;/mx:Button&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;AS&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;import mx.states.State;&lt;br /&gt;import mx.events.SliderEvent;&lt;br /&gt;import&lt;br /&gt;mx.controls.Alert;&lt;br /&gt;import flash.net.LocalConnection;&lt;br /&gt;[Bindable]&lt;br /&gt;public&lt;br /&gt;var lc:LocalConnection;&lt;br /&gt;private function initApp() : void&lt;br /&gt;{&lt;br /&gt;lc = new&lt;br /&gt;LocalConnection();&lt;br /&gt;lc.allowInsecureDomain("*");&lt;br /&gt;}&lt;br /&gt;private function&lt;br /&gt;click():void&lt;br /&gt;{&lt;br /&gt;lc.send("flex_connector", "changeText","THIS IS A TEST");&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Oke run and works like a charm.. or doesnt it?&lt;br /&gt;&lt;br /&gt;Next thing is loading the chart files...&lt;br /&gt;&lt;br /&gt;Here's how i changed the wrapper function:&lt;br /&gt;&lt;br /&gt;1. Added a symbol containing MovieClip&lt;br /&gt;2. Giving it as name MC ( its case sensitive !! )&lt;br /&gt;3. put it on X 0 and Y 0&lt;br /&gt;4. Changed the code:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;var flash_flex:LocalConnection = new&lt;br /&gt;LocalConnection();&lt;br /&gt;_root.flash_flex.allowDomain("*");&lt;br /&gt;_root.flash_flex.allowInsecureDomain("*");&lt;br /&gt;_root.flash_flex.connect("flex_connector");&lt;br /&gt;&lt;br /&gt;flash_flex.methodToExecute = function(param1:String,param2:String) {&lt;br /&gt;TEXTBOX.text = param1;&lt;br /&gt;_root.flash_flex.close();&lt;br /&gt;/*_root.chartWidth = 400;&lt;br /&gt;_root.chartHeight = 400;&lt;br /&gt;_root.strXML = param2;&lt;br /&gt;_root.MC.chartWidth = 400;&lt;br /&gt;_root.MC.chartHeight = 400;&lt;br /&gt;_root.MC.strXML = param2;*/&lt;br /&gt;_root.MC.loadMovie(param1);&lt;br /&gt;_root.param2 = param2;&lt;br /&gt;_root.interid = setInterval(interFunc,1000);&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function interFunc(){&lt;br /&gt;clearInterval(_root.interid);&lt;br /&gt;&lt;br /&gt;_root.MC.setDataXML(_root.param2);&lt;br /&gt;_root.MC._height = 200;&lt;br /&gt;_root.MC._width = 400;&lt;br /&gt;_root.MC._x = 0;&lt;br /&gt;_root.MC._y = 0;&lt;br /&gt;_root._height = 400;&lt;br /&gt;_root._width = 400;&lt;br /&gt;_root._x = 0;&lt;br /&gt;_root._y = 0;&lt;br /&gt;TEXTBOX.text = _root.param2;&lt;br /&gt;} &lt;/div&gt;&lt;br /&gt;And here are my changes to the Flex code:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br /&gt;&amp;lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="initApp()"&amp;gt;&lt;br /&gt;&amp;lt;mx:Panel x="0" y="0" width="492" height="486" layout="absolute" title="Flash 8 SWF"&amp;gt;&lt;br /&gt;&amp;lt;mx:SWFLoader source="WRAPPER.swf" scaleContent="false" width="400" height="400" x="36" y="10"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/mx:Panel&amp;gt;&lt;br /&gt;&amp;lt;mx:Button x="435" y="10" label="Button" click="click();"&amp;gt;&amp;lt;/mx:Button&amp;gt;&lt;br /&gt;&amp;lt;mx:Script&amp;gt;&lt;br /&gt;&amp;lt;![CDATA[&lt;br /&gt;import mx.states.State;&lt;br /&gt;import mx.events.SliderEvent;&lt;br /&gt;import mx.controls.Alert;&lt;br /&gt;import flash.net.LocalConnection;&lt;br /&gt;&lt;br /&gt;[Bindable]&lt;br /&gt;public var lc:LocalConnection;&lt;br /&gt;public var myXML:String="&amp;lt;chart&amp;gt;&amp;lt;set label='A' value='10' /&amp;gt;&amp;lt;set label='B' value='11' /&amp;gt;&amp;lt;/chart&amp;gt;";&lt;br /&gt;private function initApp() : void&lt;br /&gt;{&lt;br /&gt;lc = new LocalConnection();&lt;br /&gt;lc.allowInsecureDomain("*");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private function click():void&lt;br /&gt;{&lt;br /&gt;lc.send("flex_connector", "methodToExecute","Column3D.swf?flashId=MC&amp;amp;chartWidth=400&amp;amp;chartHeight=300",myXML);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;]]&amp;gt;&lt;br /&gt;&amp;lt;/mx:Script&amp;gt;&lt;br /&gt;&amp;lt;/mx:Application&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Next problem is the scale, now i have a column chart but not 400x400.. the scale is weird. Sorry but i haven't figured this out yet.&lt;br /&gt;&lt;br /&gt;Ok from here i make a jump to amCharts since FusionCharts is making a Flex compatible version. Following code creates an amChart with variables from Flex. Be sure to have the following files in your bin map:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;amcolumn.swf&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;amcolumn_data.xml ( from examples)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;amcolumn_settings.xml ( from examples)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Forget the symbols and text object from the project above.&lt;br /&gt;Create a clean flash file and put this in actions:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;var flash_flex:LocalConnection = new LocalConnection();&lt;br /&gt;_root.flash_flex.allowDomain("*");&lt;br /&gt;_root.flash_flex.allowInsecureDomain("*");&lt;br /&gt;_root.flash_flex.connect("flex_connector");&lt;br /&gt;&lt;br /&gt;_root.flash_flex.methodToExecute = function(chartswf:String)&lt;br /&gt;{&lt;br /&gt;_root.createEmptyMovieClip("holder", this.getNextHighestDepth());&lt;br /&gt;holder.loadMovie(chartswf);&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And here's the flex code:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br /&gt;&amp;lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="initApp()"&amp;gt;&lt;br /&gt;&amp;lt;mx:SWFLoader id="mySWFLOADER" source="WRAPPER.swf" scaleContent="false" width="500" height="500" x="0" y="0"/&amp;gt;&lt;br /&gt;&amp;lt;mx:Button x="435" y="10" label="Button" click="click();"&amp;gt;&amp;lt;/mx:Button&amp;gt;&lt;br /&gt;&amp;lt;mx:Script&amp;gt;&lt;br /&gt;&amp;lt;![CDATA[&lt;br /&gt;import mx.states.State;&lt;br /&gt;import mx.events.SliderEvent;&lt;br /&gt;import mx.controls.Alert;&lt;br /&gt;import flash.net.LocalConnection;&lt;br /&gt;[Bindable]&lt;br /&gt;public var lc:LocalConnection;&lt;br /&gt;private function initApp() : void&lt;br /&gt;{&lt;br /&gt;lc = new LocalConnection();&lt;br /&gt;lc.allowInsecureDomain("*");&lt;br /&gt;}&lt;br /&gt;private function click():void&lt;br /&gt;{&lt;br /&gt;lc.send("flex_connector", "methodToExecute","amcolumn.swf?settings_file=amcolumn_settings.xml&amp;amp;data_file=amcolumn_data.xml&amp;amp;flash_width="+mySWFLOADER.width+"&amp;amp;flash_height="+mySWFLOADER.height);&lt;br /&gt;}&lt;br /&gt;]]&amp;gt;&lt;br /&gt;&amp;lt;/mx:Script&amp;gt;&lt;br /&gt;&amp;lt;/mx:Application&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So far this post, good luck creating wrappers!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-2239999091690201978?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/2239999091690201978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=2239999091690201978' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/2239999091690201978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/2239999091690201978'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/03/using-flash-charts-in-flex3-application.html' title='Using Flash Charts in a Flex3 Application'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-6429915134733240512</id><published>2008-03-28T11:27:00.012+01:00</published><updated>2008-05-18T15:40:04.666+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C# ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='ODP'/><category scheme='http://www.blogger.com/atom/ns#' term='UDT'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle'/><title type='text'>C#.net communicating with UDT types in Oracle.</title><content type='html'>First headache on this blog.&lt;br /&gt;&lt;br /&gt;Im trying to call a function in oracle which needs an custom type object in C#.net. To achieve this you need the new Oracle ODP.net client software.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;note: If you want to connect to any Oracle database you have to get a oracle client, its not like MS SQL which has build in reference and you're ready to go.&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;The ODP.net software with Visual Studio Tools can be found here: &lt;a href="http://www.oracle.com/technology/software/tech/windows/odpnet/index.html"&gt;http://www.oracle.com/technology/software/tech/windows/odpnet/index.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can use an 11g client on an Oracle 9i database! Please also install the Visual studio tools you need these later.&lt;br /&gt;&lt;br /&gt;After installing the client you need to adjust the following 2 files for your connection:&lt;br /&gt;&lt;br /&gt;tnsnames.ora and sqlnet.ora&lt;br /&gt;&lt;br /&gt;My tnsnames is like this:&lt;br /&gt;&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;filki.omnext.net =&lt;br /&gt;(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=filki.omnext.net)(PORT=1521)))(CONNECT_DATA=(SID=filki)(SERVER=DEDICATED)))&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;In visual studio the connection string would be:&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;"Data Source=filki.omnext.net;UserID=test;Password=secret;"&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Now you can set your Client to connect in Visual Studio with Oracle, this is all wizzard and shouldn't be any problem :). After connection you can see your custom types created in Oracle. Right click on the type and select generate class files! After that you have a nice C# class of your UDT from Oracle.&lt;br /&gt;&lt;br /&gt;The function and my UDT im calling in Oracle is like this:&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;CREATE OR REPLACE TYPE TEST.T_NUMBER_FIELD AS&lt;br /&gt;OBJECT&lt;br /&gt;(&lt;br /&gt;AVALUE NUMBER(8) ,&lt;br /&gt;COLOUR_CODE NUMBER(2)&lt;br /&gt;);&lt;br /&gt;/&lt;br /&gt;CREATE OR REPLACE TYPE TEST.T_VARCHAR_FIELD AS OBJECT&lt;br /&gt;(&lt;br /&gt;AVALUE&lt;br /&gt;VARCHAR2(20) ,&lt;br /&gt;COLOUR_CODE NUMBER(2)&lt;br /&gt;);&lt;br /&gt;/&lt;br /&gt;CREATE OR REPLACE TYPE&lt;br /&gt;TEST.T_CONTAINER AS OBJECT&lt;br /&gt;(&lt;br /&gt;BOEKING T_VARCHAR_FIELD ,&lt;br /&gt;EENHEID_NUMMER T_VARCHAR_FIELD ,&lt;br /&gt;GEWICHT T_NUMBER_FIELD ,&lt;br /&gt;X_POS&lt;br /&gt;T_NUMBER_FIELD ,&lt;br /&gt;Y_POS T_NUMBER_FIELD ,&lt;br /&gt;Z_POS T_NUMBER_FIELD ,&lt;br /&gt;MEMBER PROCEDURE INIT&lt;br /&gt;);&lt;br /&gt;/&lt;br /&gt;CREATE OR REPLACE TYPE BODY&lt;br /&gt;TEST.T_CONTAINER&lt;br /&gt;AS&lt;br /&gt;MEMBER PROCEDURE INIT&lt;br /&gt;IS&lt;br /&gt;BEGIN&lt;br /&gt;SELF :=&lt;br /&gt;T_CONTAINER(T_VARCHAR_FIELD(NULL, NULL), T_VARCHAR_FIELD(NULL, NULL),&lt;br /&gt;T_NUMBER_FIELD(NULL, NULL),&lt;br /&gt;T_NUMBER_FIELD(NULL, NULL), T_NUMBER_FIELD(NULL,&lt;br /&gt;NULL), T_NUMBER_FIELD(NULL, NULL));&lt;br /&gt;END;&lt;br /&gt;END;&lt;br /&gt;/&lt;br /&gt;CREATE OR&lt;br /&gt;REPLACE FUNCTION TEST.FUNCTION1 ( P_CONTAINER_GEGEVENS IN OUT T_CONTAINER )&lt;br /&gt;RETURN T_CONTAINER&lt;br /&gt;IS&lt;br /&gt;V_COLOUR_CODE NUMBER(2) := 0;&lt;br /&gt;BEGIN&lt;br /&gt;V_COLOUR_CODE := 4;&lt;br /&gt;P_CONTAINER_GEGEVENS.BOEKING.COLOUR_CODE :=&lt;br /&gt;V_COLOUR_CODE;&lt;br /&gt;P_CONTAINER_GEGEVENS.EENHEID_NUMMER.COLOUR_CODE :=&lt;br /&gt;V_COLOUR_CODE;&lt;br /&gt;P_CONTAINER_GEGEVENS.GEWICHT.COLOUR_CODE := MOD(V_COLOUR_CODE&lt;br /&gt;+ 3, 10);&lt;br /&gt;P_CONTAINER_GEGEVENS.X_POS.COLOUR_CODE := MOD(V_COLOUR_CODE + 1,&lt;br /&gt;10);&lt;br /&gt;P_CONTAINER_GEGEVENS.Y_POS.COLOUR_CODE := MOD(V_COLOUR_CODE + 1, 10);&lt;br /&gt;P_CONTAINER_GEGEVENS.Z_POS.COLOUR_CODE := MOD(V_COLOUR_CODE + 1, 10);&lt;br /&gt;RETURN P_CONTAINER_GEGEVENS;&lt;br /&gt;END;&lt;br /&gt;/&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Now in C# i have created the following function to call my Oracle function with my C# UDT's&lt;br /&gt;&lt;div class="mycode"&gt;&lt;br /&gt;private T_CONTAINER colorContainer()&lt;br /&gt;{&lt;br /&gt;//Connection to Oracle&lt;/span&gt;&lt;br /&gt;OracleConnection oraclecon = new OracleConnection("Data&lt;br /&gt;Source=filki.omnext.net;User ID=test;Password=secret;");&lt;br /&gt;//Oracle PL/SQL&lt;br /&gt;Function.&lt;br /&gt;OracleCommand colourCommand = new OracleCommand("FUNCTION1",&lt;br /&gt;oraclecon);&lt;br /&gt;//It has to be a stored procedure.&lt;br /&gt;colourCommand.CommandType&lt;br /&gt;= CommandType.StoredProcedure;&lt;br /&gt;//Create my C# UDT class with values&lt;br /&gt;T_CONTAINER curContainer = new T_CONTAINER();&lt;br /&gt;curContainer.EENHEID_NUMMER = new T_VARCHAR_FIELD(tbEenheidNummer.Text);&lt;br /&gt;curContainer.BOEKING = new T_VARCHAR_FIELD(tbBoeking.Text);&lt;br /&gt;curContainer.GEWICHT = new T_NUMBER_FIELD(Decimal.Parse(tbGewicht.Text));&lt;br /&gt;curContainer.X_POS = new T_NUMBER_FIELD(numXPositie.Value);&lt;br /&gt;curContainer.Y_POS = new T_NUMBER_FIELD(numYPositie.Value);&lt;br /&gt;curContainer.Z_POS = new T_NUMBER_FIELD(numZPositie.Value);&lt;br /&gt;//Parameter&lt;br /&gt;OUT - first send the return value!!&lt;br /&gt;OracleParameter colourOutParameter = new&lt;br /&gt;OracleParameter();&lt;br /&gt;colourOutParameter.OracleDbType = OracleDbType.Object;&lt;br /&gt;colourOutParameter.Direction = ParameterDirection.ReturnValue;&lt;br /&gt;colourOutParameter.ParameterName = "P_CONTAINER_GEGEVENS2";&lt;br /&gt;colourOutParameter.UdtTypeName = "TEST.T_CONTAINER";&lt;br /&gt;colourOutParameter.Value = new T_CONTAINER();&lt;br /&gt;//Parameter IN - object&lt;br /&gt;the container object to send as input.&lt;br /&gt;OracleParameter colourInParameter =&lt;br /&gt;new OracleParameter();&lt;br /&gt;colourInParameter.OracleDbType = OracleDbType.Object;&lt;br /&gt;colourInParameter.Direction = ParameterDirection.Input;&lt;br /&gt;colourInParameter.ParameterName = "P_CONTAINER_GEGEVENS";&lt;br /&gt;colourInParameter.UdtTypeName = "TEST.T_CONTAINER";&lt;br /&gt;colourInParameter.Value = curContainer;&lt;br /&gt;//Parameters to add, first OUT&lt;br /&gt;then IN&lt;br /&gt;colourCommand.Parameters.Add(colourOutParameter);&lt;br /&gt;colourCommand.Parameters.Add(colourInParameter);&lt;br /&gt;//Connection open&lt;br /&gt;if (oraclecon.State == ConnectionState.Closed)&lt;br /&gt;oraclecon.Open();&lt;br /&gt;//Call the function.&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;colourCommand.ExecuteNonQuery();&lt;br /&gt;}&lt;br /&gt;catch (OracleException ex)&lt;br /&gt;{&lt;br /&gt;MessageBox.Show(ex.ToString(),&lt;br /&gt;"Oracle exception", MessageBoxButtons.OK, MessageBoxIcon.Error);&lt;br /&gt;oraclecon.Close();&lt;br /&gt;return null;&lt;br /&gt;}&lt;br /&gt;//Connection close&lt;br /&gt;oraclecon.Close();&lt;br /&gt;//Here's the object with filled in values.&lt;br /&gt;return&lt;br /&gt;(T_CONTAINER)colourCommand.Parameters[0].Value;&lt;br /&gt;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Remember that the return value have to come first because for SOME reason it wont work!&lt;br /&gt;&lt;br /&gt;Here's the form which helped me alot, i also posted my problem there:&lt;br /&gt;&lt;a href="http://forums.oracle.com/forums/thread.jspa?threadID=386484"&gt;http://forums.oracle.com/forums/thread.jspa?threadID=386484&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Thanks for reading, and goodluck.&lt;br /&gt;&lt;br /&gt;-Sjoerd&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-6429915134733240512?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/6429915134733240512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=6429915134733240512' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/6429915134733240512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/6429915134733240512'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/03/cnet-communicating-with-udt-types-in.html' title='C#.net communicating with UDT types in Oracle.'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4310766517884285175.post-1814913584282304622</id><published>2008-03-27T22:38:00.002+01:00</published><updated>2008-03-27T22:48:40.698+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='why'/><title type='text'>First post</title><content type='html'>Hello there,&lt;br /&gt;&lt;br /&gt;The reason i started this blog is because i had a lot of headaches last year and i want to share those to the world. From frustrating simple problems to complex never ending google searches. All combined with lovely solutions or ugly walkarrounds.&lt;br /&gt;&lt;br /&gt;Hope i can keep this blog alive (which i suppose is up to my headaches) and save some ones day for having the same headache!&lt;br /&gt;&lt;br /&gt;Enjoy,&lt;br /&gt;&lt;br /&gt;Sjoerd&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4310766517884285175-1814913584282304622?l=sdheadaches.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sdheadaches.blogspot.com/feeds/1814913584282304622/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4310766517884285175&amp;postID=1814913584282304622' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/1814913584282304622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4310766517884285175/posts/default/1814913584282304622'/><link rel='alternate' type='text/html' href='http://sdheadaches.blogspot.com/2008/03/first-post.html' title='First post'/><author><name>Sjoerd Perfors</name><uri>http://www.blogger.com/profile/10628712245364805288</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
