PHP读取ACCESS数据库实例代码
open($MM_Conn_STRING);//链接打开数据源
$query="select * from dm order by id asc";
$RS->open($query,$Conn,1,1);//执行语句,返回数据集
echo"共有:".$RS->RecordCount."条记录结果!
";//纪录数
for ($i=0;$ifields->Count;$i++)
echo $RS->fields[$i]->Name." ";//遍历字段名
echo "
";
$connect = mysql_connect("192.168.0.51", "username", "password");
while(!$RS->EOF)
{
$query = "insert into smsGames.nanjing_toponym values('";
$query .= $RS->fields["id"]->value."', '";
$query .= $RS->fields["name"]->value."', '";
$query .= $RS->fields["symbol"]->value."', '";
$query .= str_replace("\r\n", "", $RS->fields["weizhi"]->value)."', '";
$query .= $RS->fields["way"]->value."', '";
$query .= $RS->fields["class"]->value."', '";
$query .= str_replace("\r\n", "", $RS->fields["history"]->value)."', '";
$query .= str_replace("\r\n", "", $RS->fields["addr"]->value)."')";
$result = mysql_query($query, $connect);
if (!$result)
print "Error:".mysql_error()."
Query:".$query."
";
else
print $RS->fields["id"]->value." ";
$RS->MoveNext();
$i++;
}
//释放资源
$Conn->Close();
$RS=NULL;
$Conn =NULL;
?>
本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉
本文系统来源:php中文网