Database Connection with my sql

by MARIGANESH 2010-11-04 10:55:00

Step 1: Install mysql


step 2:Install the mysql-odbc-connector (3.51 or 5.1)

suppose U dont have Download mysql-odbc-connector (3.51 or 5.1)
http://dev.mysql.com/downloads/connector/odbc/3.51.html
http://dev.mysql.com/downloads/connector/odbc/5.1.html

step 3:After downloading this connector install it. You can check it is installed successfully or not from

START-> COntrol Panel->Administrative Tools ->Data Sources (ODBC).

It will open ODBC Datasource Administrator. Click ADD. You will find MYSQL ODBC 3.51 or 5.1 Driver.
--->Click MYSQL ODBC 3.51 or 5.1 Driver -->Fill that form

step 4:. After that install mysql successfully then craete a table and database insert some values.


Step 5: use this coding
<%
Dim sConnection, objConn , objRS
//Type ur own server name,databasename,usernam,password.

sConnection = "DRIVER={MySQL ODBC 5.1 Driver}; SERVER=localhost; DATABASE=tst; UID=root;PASSWORD=root123;"
Set objConn = Server.CreateObject(“ADODB.Connection”)

//open the connection

objConn.Open(sConnection)
//select some fiels from table name

Set objRS = objConn.Execute("SELECT id, name FROM tst1")
//Display every values

While Not objRS.EOF
Response.Write objRS.Fields("id") & ", " & objRS.Fields("name") & "
"
objRS.MoveNext
Wend
//close alll connectionc

objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>

Tagged in:

753
like
0
dislike
0
mail
flag

You must LOGIN to add comments