惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - 似曾相识

建立用户体验Drupal网站之分析阶段 Drupal 6.13和5.19发布 关于安装IIS NET开发几时有?把鼠标问VS2005! 走自己的路 - 似曾相识 - 博客园 关于"Server Error in '/' Application"(着急!!!) 本人有问题请教高手,谢谢! 安装动网论坛数据库的问题 爱情心理测试 变形金刚 章立民老师北京中关村图书大厦讲座 C#文本写入数据库(未解决) 吃西餐的礼仪 固定LABEL显示的行宽 把aspx文件生成html文件 如何固定GridView中的列宽? 网站首页首频图片替换代码 寻找.NET开发团队和项目 VS2005中显示代码行
C#中文本如何写入数据库?(着急!多谢!)
似曾相识 · 2007-07-18 · via 博客园 - 似曾相识

Default2.aspx

 1<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
 2
 3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 4
 5<html xmlns="http://www.w3.org/1999/xhtml" >
 6<head runat="server">
 7    <title>无标题页</title>
 8</head>
 9<body>
10    <form id="form1" runat="server">
11    <div>
12        姓名:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
13        性别:
14        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
15        <br />
16        QQ:<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
17        <br />
18        邮箱:<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox><br />
19        &nbsp;<br />
20        <br />
21        <br />
22        <asp:Button ID="Button1" runat="server" Text="Button" /></div>
23    </form>
24</body>
25</html>
26

Default2.aspx.cs

 1using System;
 2using System.Data;
 3using System.Configuration;
 4using System.Collections;
 5using System.Web;
 6using System.Web.Security;
 7using System.Web.UI;
 8using System.Web.UI.WebControls;
 9using System.Web.UI.WebControls.WebParts;
10using System.Web.UI.HtmlControls;
11using System.Data.OleDb; //这里要引用OleDb空间 
12
13public partial class Default2 : System.Web.UI.Page
14{
15    //数据库连接字符串 
16    static string strCon = @"provider = Microsoft.Jet.OLEDB.4.0;Data source = D:\liuyan\App_Data\db.mdb";
17
18    //申明连接数据源的对象和对数据源进行操作的对象 
19    OleDbConnection con = new OleDbConnection(strCon);
20    OleDbCommand cmd = new OleDbCommand();
21
22    //点击按钮添加记录 
23    protected void Button1_Click(object sender, EventArgs e)
24    {
25        string name = TextBox1.Text.Trim(); //姓名 
26        string sex = TextBox2.Text.Trim(); //性别 
27        string qq = TextBox3.Text.Trim(); //QQ 
28        string email = TextBox4.Text.Trim(); //Email 
29
30        //要插入记录的sql语句 
31        string insertText = "insert into biao(name,sex,qq,email) values('" + name + "','" + sex + "','" + qq + "','" + email + "')";
32
33        //数据源打开 
34        con.Open();
35
36        //设置操作对象的数据源 
37        cmd.Connection = con;
38
39        //要执行的SQL语句 
40        cmd.CommandText = insertText;
41
42        //执行操作 
43        cmd.ExecuteNonQuery();
44
45        //数据源关闭 
46        con.Close();
47    }

48
49    protected void Page_Load(object sender, EventArgs e)
50    {
51
52    }

53}

数据库db.mdb中表:biao

以上是代码文件,运行不出错,可是就是写不进去数据库(ACCESS),极度郁闷,敬请高人指正!不慎感激!