----- Original Message ----- From: "sdfine" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, January 28, 2002 12:06 Subject: Accessing MySQL Using ASP
> > Does anyone have a good example of accessing and displaying data in a MySQL > database using ASP and displaying it on a web page? I'm a VB programmer and > I'm new to accessing databases from the web and just need one good example > to tie everything together. > > Thanks Here's a small one off the top of my head. Obviously you will have to set up an ODBC DSN on the web server for this to work. I use MySQL with IIS 5 and ASP all the time and have no problems. <% @Language = "VBScript" %> <% Response.buffer = true %> <% Dim conDB ' ADODB connection object Dim rsBirthdays ' Query recordset Dim strSQL ' SQL query ' Create ADODB connection instance Set conDB = Server.CreateObject("ADODB.Connection") ' Create ADODB recordset instance Set rsBirthdays = Server.CreateObject("ADODB.Recordset") ' Open a recordset strSQL = "SELECT firstname, lastname, birthday FROM employees order by lastname;" rsBirthdays.Open strSQL, conDB %> <html> <body> <table border=1> <tr><th>First Name</th><th>Last Name</th><th>Birthday</th></tr> <% Do While Not rsBirthdays.EOF %> <tr> <td><%= rsBirthdays("firstname") %></td> <td><%= rsBirthdays("lastname") %></td> <td><%= FormatDateTime(rsBirthdays("birthday"), 1) %></td> <% Loop %> </table> </body> </html> <% ' Close recordset rsBirthdays.Close ' Close connection conDB.Close %> ---- A. Clausen [EMAIL PROTECTED] --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php