e-mail sales
e-mail support
Fast feedback
 
 
sales@thewebpower.com
support@thewebpower.com
page
 
WEB SITE HOSTING

 

ASP CONNECTIONS TO MYSQL

 



Home Page
Web Hosting
Order Now
About Us
Testimonials
Web Design
Web Advertising
Why Us
Support
Fast Feedback Page
Resellers



server technology

 

 

How can I connect to my MySQL database using ASP/Javascript?

The code would look like this:

<%@ LANGUAGE = JScript%>

<html>

<%

var conn,result;

conn = Server.CreateObject("ADODB.Connection");

conn.Open("DSN=YOUR_DSN;Username=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>

How can I connect to MySQL via ASP/VBScript?

The code would look like this:

<%@ 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>

Home | Web Hosting | Web Design | Web Advertising | Why us?
Support | On-line Order | Fast Feedback Page | Resellers

THE WEB POWER © 1997-2003 all rights reserved
A branch of MEDIA POWER ADVERTISING