Click to See Complete Forum and Search --> : Saving Record - AJAX


Sync
04-08-2006, 03:13 PM
Is it possible to connect with database (eg: mysql) by using AJAX?
It would be great if anyone show me the example for saving record to mysql database by using AJAX?
I found some articles but we hav to use one Server-side Script....
Any Idea.

Sync
04-08-2006, 07:43 PM
I got some coding from internet.. but conn variable is always emty("")..
Do you have any idea??

My Env:
- WinXp
- VS 6.0, .NET 2003, .NET 2005 and MySQL, MSDE and FireBird.

Any Idea?? Thanks.


<SCRIPT LANGUAGE=javascript>
<!--
function ConDB()
{
var conn = new ActiveXObject("ADODB.Connection") ;
//var conn = CreateObject("ADODB.Connection");
alert(conn);

//var connectionstring="Provider=SQLOLEDB;Password=;User ID=;Initial Catalog=;Data Source=;"
//var connectionstring="Provider=SQLOLEDB;Password=;User ID=gpctadmin;Initial Catalog=;Data Source=;"
var connecitonstring = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=127.0.0.1;DATABASE=test;UID=root;PWD=testing123;" //_ & "OPTION=" & 1
alert(connecitonstring);
if(conn != ''){
conn.Open(connectionstring);
alert(conn);
}
else{
alert("d");
}
//var rs = new ActiveXObject("ADODB.Recordset");
//rs.Open("SELECT * FROM YourTablename ", conn);

//rs.MoveFirst
//while(!rs.eof)
//{
//document.write( yourtablefieldname);
//rs.movenext;
//}

//rs.close;
//conn.close;
} //-->
</SCRIPT>
<body topmargin="0" OnLoad="javascript:ConDB()">

Sync
04-10-2006, 09:11 AM
I think this coding can't make connection with server... :(

Zak
04-15-2006, 01:07 PM
The best way to interact with a MySQL db is to write a little PHP script to except a SQL statement and return the results...