ASP.net mySQL connection

If you are using ASP.net and would like to connect to a mySQL database read on. Before you can use mySQL with ASP.net you will need to install the connector:

http://dev.mysql.com/downloads/connector/net/1.0.html

MySql.Data.dll needs to be placed within you BIN folder. 

The sub routine below will connect to a mySQL database and pull data from:

database “data1″
table “posts”
Where forumid = variable
Ordered by dateposted which is a date column

 The data is then binded to “Repeater1″.

Server can be localhost or the address of the mySQL server
UserID and password are required

code:

Sub GetPosts()

        Dim myConnection As MySqlConnection
        Dim myDataAdapter As MySqlDataAdapter
        Dim myDataSet As DataSet

        Dim strSQL As String
        Dim iRecordCount As Integer

        myConnection = New MySqlConnection(”server=mysql.provider.com; user id=SQLAdmin; password=xxxxx; database=data1; pooling=false;”)

        strSQL = “SELECT * FROM Posts where forumid=’” & forum & “‘ order by dateposted desc”

        myDataAdapter = New MySqlDataAdapter(strSQL, myConnection)
        myDataSet = New Dataset()
        myDataAdapter.Fill(myDataSet, “Posts”)

        Dim clientview As New DataView(myDataSet.Tables(”Posts”))

        Repeater1.DataSource = clientview
        Repeater1.databind()

    End Sub

JavaScript Check Screen Resolution

If you have a ASP.NET webpage and want to check the users screen resolution then display the correctly sized image the following code will help (Goes in the head of the page):

<SCRIPT type=”text/javascript”>if(screen.width >= 1600) { document.write(“<style type=’text/css’> body { background-image: url(’background1600.jpg’); background-repeat: no-repeat; background-attachment: fixed; } </style>”); }

else if (screen.width == 1280) { document.write(”<style type=’text/css’> body { background-image: url(’background1280.jpg’);background-repeat: no-repeat; background-attachment: fixed; } </style>”); }

else if (screen.width == 1024) { document.write(“<style type=’text/css’> body { background-image: url(’background1024.jpg’); background-repeat: no-repeat; background-attachment: fixed; } </style>”); }else if (screen.width == 800) { document.write(”<style type=’text/css’> body { background-image: url(’background800.jpg’); background-repeat: no-repeat; background-attachment: fixed;} </style>”); }

else { document.write(“<style type=’text/css’> body { background-image: url(’background1280.jpg’); background-repeat: no-repeat; background-attachment: fixed; } </style>”); }</SCRIPT>

Copy and past this code into notepad before your code editor:

Working example of code here:

 http://www.lervy.net/australia/

The Little Ninja (Ninjai)

Facebook graffiti

Shane Williams

Shane Williams

3 monitors or 1??

Current work set up Intel 2 GHz pc with Gig of Ram but 3 monitors:

Intel RG2 pc and 3 monitors

New RM1 PC all in one?

RM1 All in one PC

Mini ITX pc            Apple G4
Mini ITX pc
 Apple Mac G4�

My Banana

Banana Drawn on by Duff

.:Click my banana for full size:.

Photos of Me and Duff taken with Mac built in camera

Mac Photo

Mac Photo

Mac Photo
Mac Photo

My Dinner and Dessert

My Dinner

My Dessert

SQL Negative Join

“Select items from table one that dont exist in table two” 

Maybe this SQL will be useful to someone::: 

 I have been working on a website for a football team and become a little stuck with the SQL statements, I had two tables that I was using, Matches and Results.

 On the add results page I wanted to display all the current matches that had not been played, to check if a match had been played I wanted to check which match ID’s existed in Matches but not in Results:

This statement will select everything in table 1 with an ID that does not appear in table 2.

strSQL =”SELECT * FROM Table1 T1 LEFT OUTER JOIN Table2 T2 ON T1.id = T2.id WHERE T2.id IS NULL Order by date”This is the actual SQL used in my website:

strSQL =”SELECT * FROM Matches m LEFT OUTER JOIN results r ON m.id = r.id WHERE r.id IS NULL and m.team=’” & teamlist.selecteditem.value.tostring() & “‘ and m.season = ‘” & seasonID & “‘ Order by date asc”

As the site contains information for many teams and many seasons I needed to display data relevant to a certain team and season.

Master Jon