ajax 连接 mysql_ajax连接数据库并操作数据库
Response.Write("alert('用户名不能为空!请输入!')");---------------------------------------------------------------function showCustomer() {alert("ddd")var str = document.getElementById("txtvalue").value;if (str
Response.Write("");
---------------------------------------------------------------
function showCustomer() {
alert("ddd")
var str = document.getElementById("txtvalue").value;
if (str == "") {
return;
}
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "Conn.aspx?name="+str, true);
xmlhttp.send();
}
function add() {
var names = document.getElementById("names").value;
var Valuses = document.getElementById("Valuses").value;
if (names == "") {
return;
}
if (Valuses == "") {
return;
}
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
}
else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("POST", "addweb.aspx", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("names='" + names + "'&Valuses='" + Valuses + "'");
}
------------------------------------------------------------
string strconn = "Data Source=PC-201001081513;Initial Catalog=WebFirst;Integrated Security=True";
SqlConnection conn = new SqlConnection(strconn);
SqlCommand cmd = new SqlCommand();
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
string ad = Request["name"];
string sql = "select Name,Valuses,ParentId from DaoHang where name='"+ad +"'";
cmd.CommandText = sql;
cmd.Connection = conn;
// System.Data.DataSet ds = new System.Data.DataSet();
// System.Data.SqlClient.SqlDataAdapter sda = new System.Data.SqlClient.SqlDataAdapter(cmd);
// sda.Fill(ds);
// if (ds.Tables[0].Rows.Count > 0)
//{
// }
SqlDataReader ar = cmd.ExecuteReader();
while (ar.Read())
{
Response.Write(ar.GetSqlString(0)+"");
}
%>
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)