What I have here is a basic template of creating and using a DSN-less 
connection from an ASP page (using VBScript) through ADO through an ODBC 
driver into a MySQL database. I would refer you to the ADO documentation 
if you need more specifics about other options (like setting the cursor 
location (server, client), recordset types (static, dynamic, keyset, etc), 
recordset locking (read-only, batch-optimistic, etc.), retrieving the 
results, etc) This script, as written, should be executed on the server 
but could also run from a client running MSIE (assuming they also have the 
ODBC driver and the networking ability to reach the server) or from a 
system script (on either machine).  If you do run this as a system script 
you will need to change "Server.CreateObject" to "WScript.CreateObject" as 
it is executed by a different engine (not by ASP.DLL but WSCRIPT. EXE or 
CSCRIPT.EXE, depending on how it's called).

I am cross-posting this to the Win32 list in hopes that it may be helpful 
there, too.

Option Explicit

Dim oConn,sConn
Dim rsData, sSQL

set oConn = Server.CreateObject("ADODB.Connection")
set rsData = Server.CreateObject("ADODB.Recordset")

sConn = "Driver={MySQL ODBC 3.51 
Driver};SERVER=127.0.0.1;DATABASE=your_database_name;UID=a_valid_MySQL_account;PASSWORD=a_valid_password"
oConn.open sConn
sSQL = "SELECT list_of_some_fields FROM some_table(s) WHERE 
something_to_be_true"
rsData.open sSQL, oConn

You may need to adjust the DRIVER={} phrase to match what you have on your 
system. The SERVER= can take either an IP address (faster) or a DNS name 
(sometimes more flexible). (I always use IP addresses whenever I can.)

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine




Scott Hamm <[EMAIL PROTECTED]> wrote on 08/06/2004 09:51:00 AM:

> Sorry, Connecting M$ ASP to MySQL is what I meant. (just noticed the
> misunderstanding statement in subject line. My apologies)
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Friday, August 06, 2004 9:46 AM
> To: Scott Hamm
> Cc: 'Mysql ' (E-mail)
> Subject: Re: Microsoft's ASP/SQL combo

> 
> Scott, 
> 
> I think you posted to the wrong group ;-). This is the group for 
> MySQL not MS SQL Server (two totally different products)! 
> 
> You can find MANY examples for making ASP connections from the MSDN 
> site (that's where I got all of mine the first few times I needed to
> make them work). 
> 
> http://msdn.microsoft.com/ 
> 
> Use the search features. It will probably take you two or three 
> tries to figure out exactly _how_ to ask for what you need. IMHO, MS
> has done a crappy job of keeping their information organized and 
> available. There are several different libraries you can use to 
> connect your ASP site (BTW, you never said if you were using 
> Jscript, VBScript, PERL, PHP, somekinda-dot-net-language...) to an 
> MS SQL Server database (or to several other database for that matter) 
> 
> IF you are trying to connect to a MySQL database... that's a 
> different story (but you still didn't say which language you were using) 

> 
> Shawn Green
> Database Administrator
> Unimin Corporation - Spruce Pine 
> 
> Scott Hamm <[EMAIL PROTECTED]> wrote on 08/06/2004 07:11:49 AM:
> 
> > Do anyone have an ASP website that acquires info from SQL Database? I 
would
> > like to see an sample file to see how it acquires info from SQL 
Database for
> > my future Database project that I'm currently researching on....
> > 
> > 
> > Thanks in advance,
> > 
> > 
> > Scott
> > 
> > -- 
> > MySQL General Mailing List
> > For list archives: http://lists.mysql.com/mysql
> > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
> > 

Reply via email to