database.sarang.net
UserID
Passwd
Database
DBMS
ㆍMySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
MySQL Tutorials 17235 게시물 읽기
 News | Q&A | Columns | Tutorials | Devel | Files | Links
No. 17235
Using MySQL with ASP and MyODBC
작성자
정재익(advance)
작성일
2002-10-02 11:10
조회수
14,531

원본출처 : 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\) + \&nbsp;\ + 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\)%>&nbsp;<%=RS(\FIELD2\)%>&nbsp;<%=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)

%>

이 글에 대한 댓글이 총 1건 있습니다.

234

234님이 2002-10-27 21:29에 작성한 댓글입니다.
[Top]
No.
제목
작성자
작성일
조회
20485[참고] 원격에서 접속시도시 mysql 대몬이 재시작하는 경우가 있군요
문태준
2003-11-24
10667
20259[MySQL] time out(wait_timeout) 계산과 설정 (김칠봉님)
문태준
2003-10-19
14047
18411MySQL 기능 최대한 이용하는 방법
정재익
2003-01-26
26328
17235Using MySQL with ASP and MyODBC [1]
정재익
2002-10-02
14531
17063MySQL 의 간단한 설명서 [1]
정재익
2002-09-09
33126
17062too many connections 에러 해결책
정재익
2002-09-09
14027
16728MySQLmodule-1.4 설치/사용법
정재익
2002-08-05
12940
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2023 DSN, All rights reserved.
작업시간: 0.052초, 이곳 서비스는
	PostgreSQL v16.1로 자료를 관리합니다