代码如下
每次提示:INSERT INTO 语句的语法错误。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: INSERT INTO 语句的语法错误。                           ........
OleDbConnection myconn= new OleDbConnection(ConnString);
OleDbDataAdapter mycommand=new OleDbDataAdapter("Select user,email,password,hellacah from m_tacle where user='"+user.Text+"'", myconn);
DataSet ds=new DataSet();
mycommand.Fill(ds,"m_tacle");
DataTable table=ds.Tables["m_tacle"];
DataRow dr=ds.Tables["m_tacle"].NewRow();
dr[0]=username.Text.ToString();
dr[1]=password.Text.ToString();
dr[2]=email.Text.ToString();
table.Rows.Add(dr);
mycommand.InsertCommand=new OleDbCommand("insert into m_tacle(user,password,email) values('"+dr[0]+"','"+dr[1]+"'','"+dr[2]+"')",oleConn);
OleDbCommandBuilder objCommandBuilder  =new OleDbCommandBuilder(mycommand);
mycommand.Update(ds,"m_tacle");

解决方案 »

  1.   

    mycommand.InsertCommand=new OleDbCommand("insert into m_tacle(user,password,email) values("+dr[0]+","+dr[1]+","+dr[2]+")",oleConn);
    --引号用的有问题
      

  2.   

    values('"+dr[0]+"','"+dr[1]+"','"+dr[2]+"')",myconn);
    修改成了这样还是不行还是提示INSERT INTO 语句的语法错误。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: INSERT INTO 语句的语法错误。
      

  3.   

    mycommand.InsertCommand=new OleDbCommand("insert into m_tacle(user,password,email) values('"+dr[0]+"','"+dr[1]+"','"+dr[2]+"')",oleConn);
      

  4.   

    OleDbConnection myconn= new OleDbConnection(ConnString);
    OleDbDataAdapter mycommand=new OleDbDataAdapter("Select user,email,password,hellacah from m_tacle where user='"+user.Text+"'", myconn);
    DataSet ds=new DataSet();
    mycommand.Fill(ds,"m_tacle");
    DataTable table=ds.Tables["m_tacle"];
    DataRow dr=ds.Tables["m_tacle"].NewRow();dr.ItemArray[0]=username.Text.ToString();//modified
    dr.ItemArray[1]=password.Text.ToString();//modified
    dr.ItemArray[2]=email.Text.ToString();//modifiedtable.Rows.Add(dr);mycommand.InsertCommand=new OleDbCommand("insert into m_tacle(user,password,email) values('"+dr.ItemArray[0].ToString()+"','"+dr.ItemArray[1].ToString()+"','"+dr.ItemArray[2].ToString()+"')",oleConn);//modifiedOleDbCommandBuilder objCommandBuilder  =new OleDbCommandBuilder(mycommand);
    mycommand.Update(ds,"m_tacle");
      

  5.   

    提示:
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: INSERT INTO 语句的语法错误。源错误: 
    行 181:  mycommand.InsertCommand=new OleDbCommand("insert into m_tacle(user,password,email) values('"+dr[0]+"','"+dr[1]+"','"+dr[2]+"')",oleConn);
    mycommand.InsertCommand=new OleDbCommand("insert into m_tacle(user,password,email) values("+dr[0]+","+dr[1]+","+dr[2]+")",oleConn);
    这2个都试验了...
    行 182:OleDbCommandBuilder objCommandBuilder  =new OleDbCommandBuilder(mycommand);
    行 183: mycommand.Update(ds,"m_tacle");<--红色显示这里
      

  6.   

    to:swordragon(古道热肠)
    用了你这个方法还是提示错误奇怪了...
      

  7.   

    设置断点调试,然后选中语句,按下Ctrl+alt+Q,查看生成好的语句,
    然后复制到ORACLE查询分析器里,去掉前后的引号,执行语句就知道错误在什么地方了
      

  8.   

    不好意思,看错了,以为你用了Oracle数据库,抱歉
    复制到SQL查询分析器中执行
      

  9.   

    to swordragon(古道热肠)
    使用了你的方法调试
    用label1输出insert语句..
    发现赋值不了
    insert into m_tacle(user,password,email) values('','','')
      

  10.   

    insert into m_tacle([user],password,email) ...在user这个字段处加上中括号,原因你可以查一下sql的帮助,写得很清楚.
      

  11.   

    SQL保留关键字:
    action
    add
    aggregate
    all
    alter
    after
    and
    as
    asc
    avg
    avg_row_length
    auto_increment
    between
    bigint
    bit
    binary
    blob
    bool
    both
    by
    cascade
    case
    char
    character
    change
    check
    checksum
    column
    columns
    comment
    constraint
    create
    cross
    current_date
    current_time
    current_timestamp
    data
    database
    databases
    date
    datetime
    day
    day_hour
    day_minute
    day_second
    dayofmonth
    dayofweek
    dayofyear
    dec
    decimal
    default
    delayed
    delay_key_write
    delete
    desc
    describe
    distinct
    distinctrow
    double
    drop
    end
    else
    escape
    escaped
    enclosed
    enum
    explain
    exists
    fields
    file
    first
    float
    float4
    float8
    flush
    foreign
    from
    for
    full
    function
    global
    grant
    grants
    group
    having
    heap
    high_priority
    hour
    hour_minute
    hour_second
    hosts
    identified
    ignore
    in
    index
    infile
    inner
    insert
    insert_id
    int
    integer
    interval
    int1
    int2
    int3
    int4
    int8
    into
    if
    is
    isam
    join
    key
    keys
    kill
    last_insert_id
    leading
    left
    length
    like
    lines
    limit
    load
    local
    lock
    logs
    long
    longblob
    longtext
    low_priority
    max
    max_rows
    match
    mediumblob
    mediumtext
    mediumint
    middleint
    min_rows
    minute
    minute_second
    modify
    month
    monthname
    myisam
    natural
    numeric
    no
    not
    null
    on
    optimize
    option
    optionally
    or
    order
    outer
    outfile
    pack_keys
    partial
    password
    precision
    primary
    procedure
    process
    processlist
    privileges
    read
    real
    references
    reload
    regexp
    rename
    replace
    restrict
    returns
    revoke
    rlike
    row
    rows
    second
    select
    set
    show
    shutdown
    smallint
    soname
    sql_big_tables
    sql_big_selects
    sql_low_priority_updates
    sql_log_off
    sql_log_update
    sql_select_limit
    sql_small_result
    sql_big_result
    sql_warnings
    straight_join
    starting
    status
    string
    table
    tables
    temporary
    terminated
    text
    then
    time
    timestamp
    tinyblob
    tinytext
    tinyint
    trailing
    to
    type
    use
    using
    unique
    unlock
    unsigned
    update
    usage
    values
    varchar
    variables
    varying
    varbinary
    with
    write
    when
    where
    year
    year_month
    zerofill