qq_29017467 2015-11-26 12:44 采纳率: 0%
浏览 1238

数据库基础问题,ASP.NET中添加语句的错误

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;

public partial class Uzc : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
    OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("app_data/student.mdb"));
    conn.Open();
    OleDbCommand mycmd = new OleDbCommand();
    string sql = "Insert Into User(Uname,Password,E-mail)Valuse('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox4.Text + "')";
    mycmd.CommandText = sql;
    mycmd.Connection = conn;
    bool dd = true;
    try
    {
        mycmd.ExecuteNonQuery();
    }
    catch
    {
        dd = false;
    }
    finally
    {
        mycmd.Dispose();
        conn.Close();
        conn.Dispose();
    }
    if (dd)
    {
        string strMessage;
        strMessage = "用户昵称:" + TextBox1.Text;
        strMessage = strMessage + "<br>密码:" + TextBox2.Text;
        strMessage = strMessage + "<br>确认密码:" + TextBox3.Text;
        strMessage = strMessage + "<br>电子邮箱:" + TextBox4.Text;
        Label1.Text = strMessage + "<br>" + TextBox1.Text + ",注册成功!";
    }
}
protected void Button2_Click(object sender, EventArgs e)
{
    TextBox1.Text = " ";
    TextBox2.Text = " ";
    TextBox3.Text = " ";
    TextBox4.Text = " ";
}

}

 string sql = "Insert Into User(Uname,Password,E-mail)Valuse('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox4.Text + "')";

他总是说我添加语句错误,可是我都是改了好几遍都还是这个错误。

  • 写回答

3条回答 默认 最新

  • qq_29017467 2015-11-26 12:44
    关注

    这是我相关的数据库数据图片说明

    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试