Connecter une base Mysql a un script ASP ou VBS

Voici la syntaxe :

 Set cnx = CreateObject("ADODB.Connection")
 
 sServerName= "ip_du_serveur_mysql"
 sDatabase="nom_de_la_base"
 sUserName="cuser"
 SPassword="password"


 l_base = "Driver={MySQL ODBC 5.1 Driver};" & "Server=" & sServerName &  ";Port=3306;"
 l_base = l_base & "Database=" & sDatabase & ";"
 l_base = l_base & "User=" & sUserName & ";Password=" & SPassword & "; Option=3;"
 cnx.open l_base

 sql="select * from table"
 Set rs = CreateObject("ADODB.Recordset")
rs.CursorLocation = 3 ' adUseClient   2: useserver

rs.Open sql, cnx, 3, 3

if rs.recordcount > 0 then
 msgbox ("cnxok " & rs.fields("CodeUser"))
end if
rs.close
set rs = nothing

  




Commentaires

Pas de commentaire

Laissez un commentaire

Commenting is restricted to registered users only. Please register or login now to submit a comment.