⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writedb.aspx

📁 ajax+asp的留言簿
💻 ASPX
字号:
<%@ Page language="C#" debug="true"%>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        Regex r = new Regex(@"([0-9]{2})(\d{2})(\d{2})(\s{1,})([^\s]{1}.+)");
        Match m;
        string ConnStr = "provider=microsoft.jet.oledb.4.0;data source=" + Server.MapPath("db.mdb"), sql = "";
        OleDbConnection cn = new OleDbConnection(ConnStr);
        OleDbCommand cm;
        string TempStr = "",pid="",cid="",lid="",Space="",Name="";
        StreamReader sr = new StreamReader(Server.MapPath("1.txt"));
        cn.Open();
        while (sr.Peek() != -1)
        {
            TempStr = sr.ReadLine().Trim();
            m = r.Match(TempStr);
            if (m != null)
            {
                pid = m.Groups[1].Value;
                cid = m.Groups[2].Value;
                lid = m.Groups[3].Value;
                Space = m.Groups[4].Value;
                Name = m.Groups[5].Value.Replace(" ","");
                switch (Space.Length)
                {
                    case 1://pro
                        sql = "insert into pro(pid,proname) values(" + pid + ",'" + Name + "')";
                        break;
                    case 2://city
                        sql = "insert into city(pid,cid,cityname) values(" + pid + "," + cid + ",'" + Name + "')";
                        break;
                    case 3://location
                        sql = "insert into location(pid,cid,lid,locationname)values("+pid+"," + cid + "," + lid + ",'" + Name + "')";
                        break;
                    default:
                        break; 
                }
                cm = new OleDbCommand(sql,cn);
                cm.ExecuteNonQuery();//插入数据
            }
        }
        sr.Close();
        cn.Close();
        cn.Dispose();
    }
</script>
<html>
<head>
  <meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
 </body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -