下边是一段读数据的脚本,直接拷贝保存为html文件即可
<script language="javascript">
//用 JavaScript 写服务器端连接数据库的代码示例
var conn = new ActiveXObject("ADODBConnection");
connOpen("DBQ=11mdb;DRIVER={Microsoft Access Driver (mdb)};");
var rs = new ActiveXObject("ADODBRecordset");
var sql="select from taba";
rsopen(sql, conn);
shtml = "<table width='100%' border=1>";
shtml +="<tr bgcolor='#f4f4f4'><td>au_id</td><td>au_lname</td><td>au_fname</td></tr>";
while(!rsEOF)
{
shtml += "<tr><td>" + rs("aid") + "</td><td>" + rs("aa") + "</td><td>" + rs("ab") + "</td></tr>";
rsmoveNext;
}
shtml += "</table>";
documentwrite(shtml);
rsclose();
rs = null;
connclose();
conn = null;
</script>
string sql;
sql = "insert into Users(Name,Pwd) values(";
sql += "'"+ txt用户名Text + "',";
sql += "'"+ txt密码Text + "')";
SqlConnection sqlConnection1= new SqlConnection();
sqlConnection1ConnectionString = "server=localhost;user id=sa;password=;initial catalog=BookStore";
sqlConnection1Open();
SqlCommand sqlCommand1 = new SqlCommand();
sqlCommand1Connection = sqlConnection1;
sqlCommand1CommandText = sql;
sqlCommand1ExecuteNonQuery();
sqlConnection1Close();
ResponseWrite("<script language='javascript'> windowalert('数据已保存!');</script >");
以上就是关于怎么样往html格式网页中加入数据库全部的内容,包括:怎么样往html格式网页中加入数据库、在ASP.NET里怎么把里面网页的用户信息添加到数据库中、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)