采用的数据库是access 字段类型全是文本的类型
 语句
insert into post ( postid,postname,post_address,sex,country,title,mobile,email,state,postmethod,IsMem,describe ) 
values
( 'P-1000-45456','45645645645','中国456546','','','456546','','','无退回确认收到','','','') 在vs 调试 老是报insert 语法语句错误 把这个语句在acess 中执行 可以的  找了很长时间 也没发现错在哪里  字段名 好像没有access 中的关键字吧

解决方案 »

  1.   

    insert into post ( postid,postname,post_address,sex,country,title,mobile,email,state,postmethod,IsMem,describe ) 
    values 
    ( 'P-1000-45456',
    '45645645645',
    '中国456546',
    '',
    '',
    '456546',
    '',
    '',
    '无退回确认收到','
    ',
    '',
    '') 

    这乱了
      

  2.   

    insert into post
    select 'P-1000-45456','45645645645','中国456546','','','456546','','','无退回确认收到','','','' 
      

  3.   

     这个是调用的方法 
    public class DataAccess
            {
                public static int ExecuteNonQuery(string CmdText)
                {                using (OleDbConnection conn = Get_Connetion())
                    {
                        OleDbCommand cmd = conn.CreateCommand();
                        try
                        {
                            conn.Open();
                            cmd.CommandText = CmdText;
                            return cmd.ExecuteNonQuery();
                        }
                        catch (OleDbException ex)
                        {
                            throw new Exception(ex.Message);
                        }
                        finally
                        {
                            cmd.Dispose();
                        }
                    }
                } 定义的语句
    string strInsert = string.Format("insert into post ( postid,postname,post_address,sex,country,title,mobile,email,state,postmethod,IsMem,describe ) values( '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')", drop1.SelectedItem.Value.ToString () + "-" + TextBox1.Text.ToString(), TextBox2.Text + Request.Form["nameE"], Request.Form["post_address"] + Request.Form["txtpost_address"], Request.Form["sex"], Request.Form["country"], Request.Form["title"], TextBox4.Text, TextBox3.Text, Request.Form["effect1"] + Request.Form["effect2"] + Request.Form["record"], Request.Form["post"] + Request.Form["post1"], Request.Form["IsNum"], Request.Form["describe"]);
    调用的方法 
    if (Dal.Dal.DataAccess.ExecuteNonQuery(strInsert) == 1)
                    {
                        Response.Write("<script>alert('恭喜,操作成功!')</script>");                }
                   else
                    {
                        Response.Write("<script>alert('操作失败')</script>");                }
      

  4.   

    Get_Connetion() 是定义连接数据库字符串的方法
     
    public static OleDbConnection Get_Connetion()
                {
                    string path = HttpContext.Current.Server.MapPath("~/App_Data/pizza.mdb");                OleDbConnection connection = new OleDbConnection(@"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" + path);
                    return connection;            }
      

  5.   

    你直接用INSERT TB(COL1,..)SELECT COL1 ...这样试试?
      

  6.   

    N'P-1000-45456'  
    加个N''试试
      

  7.   


    string strInsert = string.Format("insert into post ( 
    postid,postname,post_address,sex,country,title,mobile,email,state,postmethod,IsMem,describe ) 
    values
    ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')",drop1.SelectedItem.Value.ToString () + "-" + TextBox1.Text.ToString(), 
    TextBox2.Text + Request.Form["nameE"], 
    Request.Form["post_address"] + Request.Form["txtpost_address"], 
    Request.Form["sex"], 
    Request.Form["country"], 
    Request.Form["title"], 
    TextBox4.Text, 
    TextBox3.Text,
    Request.Form["effect1"] + Request.Form["effect2"] + Request.Form["record"], Request.Form["post"] + Request.Form["post1"],
    Request.Form["IsNum"],
    Request.Form["describe"]);这是我要操作的sql语句 获取页面的值是没有问题的  就是在vs中老报 insert into 语句语法错误
    你把 这个sql调试时 放在access 中去执行是可以的  我现在想知道哪里出现了错误 是字段名中有access关键字吗?  
      

  8.   

       问题 还是自己给解决啦 原来是这个字段名搞的鬼  describe是access的关键字  真是很郁闷 搞了一下 才排出了错误? 感谢大家的跟帖 !