원본출처 : http://www.dwam.net/mysql/asp_myodbc.asp#conn
Complete MyODBC options list and how to use them (for DSN or DSN-Less connections)
MyODBC connections strings samples
learn how to connect MySQL databases through MyODBC from your ASP scripts
ASP and WSH samples for MyODBC / MySQL : ADO with MyODBC
this package contains the \modified for ASP and WSH (vbs)\ versions of the VB example provided by MySQL in the MyODBC documentation. Check the screencap of the WSH version or the ASP demo online. Check the readme before downloading here!
ASP sample for MyODBC / MySQL : DWAMUploader
DWAMUploader is a modified version of the Pure ASP Upload Script provided for Access at www.asp101.com. This version allows to upload files into a MySQL database with longblob fields (or to disk) from an ASP page. Obviously, it also gets back the data from the db for a direct display or a download. There is no DWAMUploader demo for security reasons, but a nice screencap of what you should get after install. Check the readme before downloading here!
ASP sample for MyODBC / MySQL : DWAM URL Organizer
this example will help you to build such a script. Check the readme before downloading here!
ASP sample for MyODBC / MySQL : DWAM Event Organizer
based on an original script written for Access, you might have a look to this new demo version modified to work with MySQL. Use \TEST\ account to run the demo. As the server is in France and script uses MS.Locale, all dates/times appear in french but should follow your system settings. Downloadable soon!
--------------------------------------------------------------------------------
MyODBC options (taken from the original MyODBC readme.win)
MyODBC has a new nice interface to the different MyODBC options. (On Unix or when using DSN-Less connection strings in ASP or VB, the option is still a number.
The Option argument is used to tell MyODBC that the client isn\t 100% ODBC compliant. The following options are listed in the same order as they appear in the MyODBC connect screen:
1 The client can\t handle that MyODBC returns the real width of a column.
2 The client can\t handle that MySQL returns the true value of affected rows. If this flag is set then MySQL returns \found rows\ instead. One must have MySQL 3.21.14 or newer to get this to work.
4 Make a debug log in c:\myodbc.log. This is the same as putting
MYSQL_DEBUG=d:t:O,c::\myodbc.log in AUTOEXEC.BAT
8 Don\t set any packet limit for results and parameters.
16 Don\t prompt for questions even if driver would like to prompt
32 Simulate a ODBC 1.0 driver in some context.
64 Ignore use of database name in \database.table.column\. (MySQL 3.22)
128 Force use of ODBC manager cursors (experimental)
256 Remove use of extended fetch (experimental)
512 Pad CHAR fields to full column length.
1024 SQLDescribeCol() will return fully qualifed column names
2048 Use compressed protocol (if server supports it)
4096 Tell server to ignore space after function name and before \(\ (needed by PowerBuilder). This will make all function names keywords!
8192 Connect with named pipes to a mysqld server running on NT.
16384 Change LONGLONG columns to INT columns, as some applications can\t handle LONGLONG or BIGINT.
32768 Return \user\ as Table_qualifier and Table_owner from SQLTables (test)
65536 Read my.cnf
131072 Add some extra safety checks (should not bee needed but...)
262144 Disable the new transaction support (To avoid newly introduced bugs)
If you want to have many options, you should add the above flags!
For example Option 12 (4+8) gives you debugging without package limits!
Some clients that must set some MySQL options to work properly. On Win32 one have to check the specific option in the ODBC manager for the database connection.
BDE applications: 1 or 3 (Don\t optimize column widths + Return matching rows)
Visual Objects: 1 (Don\t optimize column widths)
Vision: 2 (Return matching rows)
Active Server Pages (ASP): 2 (Return matching rows)
Access 7.0: 2 (Return matching rows)
Access 2.0: 2+32 (Return matching rows + Simulate ODBC 1.0)
ODBCETE32 + quiktest: 512+1 (Don\t optimize column widths + \Pad CHAR)
Visual Basic / ADO: 2+16384 (Return matching rows + Change BIGINT to INT)
Based on my experience with ASP/MyODBC, I should advise to use :
OPTION=16387 for ASP/ADO with MyODBC 2.50 drivers,
OPTION=3 for ASP/ADO with MyODBC 3.51 drivers (which now supports BIGINT).
See below for connection strings examples.
--------------------------------------------------------------------------------
Here are many ways of connecting to MySQL databases through ASP
when you have MyODBC installed on the web server at least :
javascript connection (ODBC DSN required)
<%@ LANGUAGE = JScript%>
<html>
<%
var conn,result;
conn = Server.CreateObject(\ADODB.Connection\);
conn.Open(\DSN=YOUR_DSN;User=YOUR_ID;Password=YOUR_PWD\);
result=conn.Execute(\SELECT * FROM table\);
while (!result.eof) {
Response.Write(result(\FIELD1\) + \ : \ + result(\FIELD2\) + \ \ + result(\FIELD3\) + \<BR>\);
result.MoveNext();
}
result.close();
%>
</body>
</html>
--------------------------------------------------------------------------------
vbscript connection (ODBC DSN required)
<%@ LANGUAGE=\VBSCRIPT\ %>
<%
Set MyConn = Server.CreateObject(\ADODB.Connection\)
MyConn.Open \YOUR_DSN\
SQL_query = \SELECT * FROM your_table WHERE your_field LIKE \%abc%\;\
Set RS = MyConn.Execute(SQL_query)
%>
<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
</HEAD>
<BASEFONT FACE=\arial\>
<BODY>
<p><b><% Response.Write SQL_query %></b></p>
<%while not RS.eof%>
<%=RS(\FIELD1\)%> <%=RS(\FIELD2\)%> <%=RS(\FIELD3\)%><br>
<%RS.MoveNext%>
<%wend%>
<%
RS.Close
MyConn.Close
%>
</BODY>
</HTML>
--------------------------------------------------------------------------------
vbscript connection (DSN LESS)
<%@ LANGUAGE=\VBSCRIPT\ %>
<%
strConnection = \driver={MySQL};server=212.155.113.2;uid=YOUR_ID;pwd=YOUR_PWD;database=YOUR_DB;option=NUM\
Set adoDataConn = Server.CreateObject(\ADODB.Connection\)
adoDataConn.Open strConnection
strQuery = \SELECT * FROM your_table;\
Set RS = adoDataConn.Execute(strQuery)
%>
|