Tiernan OTooles Programming Blog

code and programming stuff from the hairy bloke!

April 2004 - Posts

First code post to my new .net site!

this is basicly the same post as i posted to my other site, but now here. so, as a CC of the post, here is pretty much everything i posted before! Enjoy! Ohhh, and if someone knows a really easy of posting code to a blog, like converting from VB.NET code to HTML quickly, please post a comment! Thanks.

Ok. the following code is something i use a fair amount. There would be something in a table with information in it like the following:

45,43,56,77,22,33

This would repesent, lets say as an example, an order for a user. so the user would have bought them products in a single purchase. To get the information about the products, i send that string into a function that splits it and returns a SQL statement. Now, the following code includes a button for testing it. If you see any better ways of doing this, please post a reply!

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        MsgBox(test(";1;2;3;4;5;"))

End Sub

Private Function test(ByVal list As String) As String

        Dim sql As String

        sql = "select * from products where productid = "

        Dim seperator As String = ""

        Dim x As Array

        Dim i As Integer

        x = Split(list, ";")

        For i = 0 To x.Length - 1

            If x(i) <> "" Then

                sql += seperator & x(i)

                seperator = " or productid =  "

            End If

        Next

        Return sql

End Function

Posted: Apr 30 2004, 01:05 PM by tiernanotoole | with 1 comment(s)
Filed under:
my new .NET programming and code Blog
So, here we are! a new weblog! this is now my coding blog. I have a few blogs already, but i never wrote up a "who am i" kind of page on them. So, heres a start. My name is Tiernan O'Toole, and im currenlty a vendor for Microsoft Ireland. Im an MCP in VB6 Desktop Applications, and im learning VB.NET and ASP.NET at the moment. So, this blog will hopefully tie in with my other blog, but it will be seperate. now to build an Aggregator that will take all my RSS feeds and make them into one.... that could be my first major project. watch this space!
Posted: Apr 30 2004, 06:35 AM by tiernanotoole | with no comments
Filed under:
More Posts