Zmey2
asked on
Connect to MySQL without driver
Is there a way to connect to MySQL database and execute query without installing any driver software on client (like MyODBC ?)
Thanks in advance.
Thanks in advance.
//script for connect to mysql db
$db = "dbxxx";
$hostname="localhost";
$username="userxxx";
$password="xxx";
if (!$dbh=mysql_connect($host name,$user name,$pass word))
{
echo mysql_error();
exit;
}
//select default db
mysql_select_db($db,$dbh);
$sql = "select * from tablex";
if (!$res=mysql_query($sql,$d bh))
{
echo mysql_error();
exit;
}
$row=mysql_fetch_row($res) ;
$db = "dbxxx";
$hostname="localhost";
$username="userxxx";
$password="xxx";
if (!$dbh=mysql_connect($host
{
echo mysql_error();
exit;
}
//select default db
mysql_select_db($db,$dbh);
$sql = "select * from tablex";
if (!$res=mysql_query($sql,$d
{
echo mysql_error();
exit;
}
$row=mysql_fetch_row($res)
ASKER
Is that a php script?
How can i call it from VB?
How can i call it from VB?
Ow sorry.
Try this:
************************** *********
Dim rs As ADODB.Recordset
dim cn as adodb.Connection
Set cn = CreateObject("ADODB.Connec tion")
cn.Open "DRIVER={MYSQL};SERVER=MyS ERVER;DATA BASE=User1 ;UID=sa;PW D=mypasswo rd;"
sql = "select * from mytable"
Set rs = CreateObject("ADODB.RECORD SET")
rs.Open sql, cn
while not rs.eof
.
.
rs.movenext
wend
rs.close
set rs = nothing
cn.close
set cn=nothing
Try this:
**************************
Dim rs As ADODB.Recordset
dim cn as adodb.Connection
Set cn = CreateObject("ADODB.Connec
cn.Open "DRIVER={MYSQL};SERVER=MyS
sql = "select * from mytable"
Set rs = CreateObject("ADODB.RECORD
rs.Open sql, cn
while not rs.eof
.
.
rs.movenext
wend
rs.close
set rs = nothing
cn.close
set cn=nothing
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
here are the links which list out MySQL connection method.
http://www.connectionstrings.com
http://www.able-consulting.com/MDAC/ADO/Connection/ODBC_DSNLess.htm#ODBCDriverForMySQL