帮忙看一下PHP与ACCESS的错误
Fatalerror:Uncaughtexception'com_exception'withmessage'<b>Source:</b>MicrosoftJETData...
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft JET Database Engine<br/><b>Description:</b> INSERT INTO 语句的语法错误。' in D:\AppServ\www\2.php:10 Stack trace: #0 D:\AppServ\www\2.php(10): com->open('insert into inf...', Object(com), 1, 3) #1 {main} thrown in D:\AppServ\www\2.php on line 10
<?PHP
$conn = @new COM("ADODB.Connection") or die ("ADO连接失败!");
$connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" . realpath("member.mdb");
$conn->Open($connstr);
$rs = @new COM("ADODB.RecordSet");
$sql = "insert into info (UserName,Password) values ('qqqqqq','wqwqwqwq')";
$rs->open($sql,$conn,1,3);
$rs->close();
?> 展开
<?PHP
$conn = @new COM("ADODB.Connection") or die ("ADO连接失败!");
$connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" . realpath("member.mdb");
$conn->Open($connstr);
$rs = @new COM("ADODB.RecordSet");
$sql = "insert into info (UserName,Password) values ('qqqqqq','wqwqwqwq')";
$rs->open($sql,$conn,1,3);
$rs->close();
?> 展开
展开全部
乍一看就是建立COM发生异常和你使用的语法有误,估计是链接Access的驱动用得不正确还有就是用ADODB的方法有误!我帮你重新写了一下,你看看吧,代码如下:
$conn=new COM("ADODB.Connection") or die("Conn failed!");
$dsn="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=".realpath("member.mdb").";Uid=Admin;Pwd=;"; //这一句中的Uid和Pwd分别是Access里打开的用户名和密码,如果没有可不要,默认的用户名是Admin,密码就是设置打开时的密码,若没有就把“Uid=Admin;Pwd=;”这一句去掉,我写出来只是为了更详细的说明。
$conn->open($dsn);
$sql = "INSERT INTO info (UserName,Password) VALUES('qqqqqq','wqwqwqwq')";
$conn->Execute($sql);
$conn->close();
unset($conn,$sql,$dsn);
$conn=new COM("ADODB.Connection") or die("Conn failed!");
$dsn="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=".realpath("member.mdb").";Uid=Admin;Pwd=;"; //这一句中的Uid和Pwd分别是Access里打开的用户名和密码,如果没有可不要,默认的用户名是Admin,密码就是设置打开时的密码,若没有就把“Uid=Admin;Pwd=;”这一句去掉,我写出来只是为了更详细的说明。
$conn->open($dsn);
$sql = "INSERT INTO info (UserName,Password) VALUES('qqqqqq','wqwqwqwq')";
$conn->Execute($sql);
$conn->close();
unset($conn,$sql,$dsn);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询