admin管理员组文章数量:1394130
I tried the following code for establishing a connection with a database(MS Access)..But am getting an error as "Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype"
<html>
<head>
<title>Insertion</title>
<script type="text/javascript" language="JavaScript" >
function AddRecord(form) {
var cn = new ActiveXObject("ADODB.Connection");
var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\\Users\\deepakgopal\\Desktop\\Testing\\Database3.mdb";
cn.Open(strConn);
var rs = new ActiveXObject("ADODB.Recordset");
var SQL = "select count(*) from data";
rs.Open(SQL, cn);
alert(rs(0));
rs.AddNew
rs.Fields("VDI") = Request.Form("vdi");
rs.Fields("Staff") = Request.Form("staff");
rs.Update;
rs.Close();
cn.Close();
}
</script>
</head>
<body style="margin:0 auto;">
VDI: <input type="text" id="tname" name="vdi" />
<br />
Staff : <input type="text" id="tpwd" name="staff" />
<br />
<input type="button" id="btnsbt" name="btnsbt" value="Login" onclick="AddRecord()" /><br />
</body>
</html>
I tried the following code for establishing a connection with a database(MS Access)..But am getting an error as "Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype"
<html>
<head>
<title>Insertion</title>
<script type="text/javascript" language="JavaScript" >
function AddRecord(form) {
var cn = new ActiveXObject("ADODB.Connection");
var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\\Users\\deepakgopal\\Desktop\\Testing\\Database3.mdb";
cn.Open(strConn);
var rs = new ActiveXObject("ADODB.Recordset");
var SQL = "select count(*) from data";
rs.Open(SQL, cn);
alert(rs(0));
rs.AddNew
rs.Fields("VDI") = Request.Form("vdi");
rs.Fields("Staff") = Request.Form("staff");
rs.Update;
rs.Close();
cn.Close();
}
</script>
</head>
<body style="margin:0 auto;">
VDI: <input type="text" id="tname" name="vdi" />
<br />
Staff : <input type="text" id="tpwd" name="staff" />
<br />
<input type="button" id="btnsbt" name="btnsbt" value="Login" onclick="AddRecord()" /><br />
</body>
</html>
Share
Improve this question
edited Feb 20, 2014 at 10:00
user3094600
asked Feb 20, 2014 at 9:52
user3094600user3094600
291 gold badge2 silver badges7 bronze badges
2
- FYI: this code only for Internet Explorer – Zam Commented Feb 20, 2014 at 10:03
- You also miss tag <FORM> – Zam Commented Feb 20, 2014 at 10:04
1 Answer
Reset to default 5The Recordset you are retrieving only contains a single row with a single column containing the count (COUNT(*)
) of all records in the table. That Recordset contains no other information and is not updatable.
If you want to add records to the table you need to .Close
that recordset and then re-open it using an SQL mand like SELECT * FROM data
(note: no COUNT()
). That should allow you to use .AddNew
and .Update
to insert new records.
本文标签: Connecting to MS Access using JavascriptStack Overflow
版权声明:本文标题:Connecting to MS Access using Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744086828a2588677.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论