OleDbConnection conn2 = new OleDbConnection();
            conn2.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;" + "Data Source=" + Server.MapPath("App_Data/db1.mdb");
            conn2.Open();            string strIns = "insert into "+TextBox2.Text+" select * from 图书信息 where 图书编号=" + int.Parse(TextBox1.Text);                        OleDbCommand com2 = new OleDbCommand(strIns, conn2);            com2.ExecuteNonQuery();
            conn2.Close();           
        }

解决方案 »

  1.   

    strIns的内容放在数据库中执行一下看看
      

  2.   

      其他的没问题,你调试下,吧SQL语句,取下来到数据库执行一遍试试。
      

  3.   

    ExecuteNonQuery();不返回任何行
    对于 UPDATE、INSERT 和 DELETE 语句,返回值为该命令所影响的行数。如果正在执行插入或更新操作的表上存在触发器,则返回值包括受插入或更新操作影响的行数以及受一个或多个触发器影响的行数。对于所有其他类型的语句,返回值为 -1。如果发生回滚,返回值也为 -1。
      

  4.   


    同意,输出sql,先在数据中执行看看
      

  5.   

    access 不支持楼主的那种写法!!
      

  6.   

    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Data.OleDb;namespace 网上书店
    {
        public partial class WebForm1 : System.Web.UI.Page
        {        protected void Page_Load(object sender, EventArgs e)
            {
               
                if((string)(Session["Pass"])!="yes")
                {
                    Response.Write("<script language=javascript>alert('您尚未登陆!');</script>");
                    Server.Transfer("Default.aspx");
                }
                else
                {
                    Page.Title = "欢迎选购!";
                    Label1.Text =(string)(Session)["name"];
                   }          
        }        protected void Button1_Click(object sender, EventArgs e)
            {            OleDbConnection conn = new OleDbConnection();
                conn.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;" + "Data Source=" + Server.MapPath("App_Data/db1.mdb");
                conn.Open();            string strSql = "Select *from 图书信息 Where 图书编号 =" + int.Parse(TextBox1.Text);
                
                OleDbCommand com = new OleDbCommand(strSql, conn);
                OleDbDataReader dr = com.ExecuteReader();
                GridView2.DataSource = dr;
                //GridView2.DataBind();
                Label2.Text = "您成功选中了一本书!";
                conn.Close();
                OleDbConnection conn2 = new OleDbConnection();
                conn2.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;" + "Data Source=" + Server.MapPath("App_Data/db1.mdb");
                conn2.Open();            string strIns = "insert into "+TextBox2.Text+" select * from 图书信息 where 图书编号=" + int.Parse(TextBox1.Text);                        OleDbCommand com2 = new OleDbCommand(strIns, conn2);
                try
                {
                    conn.Open();
                    com2.ExecuteNonQuery();
                    this .
                }            com2.ExecuteNonQuery();
                conn2.Close();           
            }        protected void Button2_Click(object sender, EventArgs e)
            {
               
                         
            }        protected void Button3_Click(object sender, EventArgs e)
            {
                Session["pass"] = "yes";
                Response.Redirect("WebForm3.aspx");        }        protected void Button4_Click1(object sender, EventArgs e)
            {
                OleDbConnection conn1 = new OleDbConnection();
                conn1.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;" + "Data Source=" + Server.MapPath("App_Data/db1.mdb");
                conn1.Open();            string strCre = " create table " + TextBox2.Text + "(书名 varchar(50),图书编号 int primary key,作者 varchar(30),出版社 varchar(50),图书售价 money,简介 varchar(100))";            OleDbCommand com1 = new OleDbCommand(strCre, conn1);            com1.ExecuteNonQuery();
                conn1.Close();
                Session["dingdan"] = TextBox2.Text;
            }
        }
    }
      

  7.   

    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Data.OleDb;namespace 网上书店
    {
        public partial class WebForm1 : System.Web.UI.Page
        {        protected void Page_Load(object sender, EventArgs e)
            {
               
                if((string)(Session["Pass"])!="yes")
                {
                    Response.Write("<script language=javascript>alert('您尚未登陆!');</script>");
                    Server.Transfer("Default.aspx");
                }
                else
                {
                    Page.Title = "欢迎选购!";
                    Label1.Text =(string)(Session)["name"];
                   }          
        }        protected void Button1_Click(object sender, EventArgs e)
            {            OleDbConnection conn = new OleDbConnection();
                conn.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;" + "Data Source=" + Server.MapPath("App_Data/db1.mdb");
                conn.Open();            string strSql = "Select *from 图书信息 Where 图书编号 =" + int.Parse(TextBox1.Text);
                
                OleDbCommand com = new OleDbCommand(strSql, conn);
                OleDbDataReader dr = com.ExecuteReader();
                GridView2.DataSource = dr;
                //GridView2.DataBind();
                Label2.Text = "您成功选中了一本书!";
                conn.Close();
                OleDbConnection conn2 = new OleDbConnection();
                conn2.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;" + "Data Source=" + Server.MapPath("App_Data/db1.mdb");
                conn2.Open();            string strIns = "insert into "+TextBox2.Text+" select * from 图书信息 where 图书编号=" + int.Parse(TextBox1.Text);                        OleDbCommand com2 = new OleDbCommand(strIns, conn2);
               
                com2.ExecuteNonQuery();
                conn2.Close();           
            }        protected void Button2_Click(object sender, EventArgs e)
            {
               
                         
            }        protected void Button3_Click(object sender, EventArgs e)
            {
                Session["pass"] = "yes";
                Response.Redirect("WebForm3.aspx");        }        protected void Button4_Click1(object sender, EventArgs e)
            {
                OleDbConnection conn1 = new OleDbConnection();
                conn1.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;" + "Data Source=" + Server.MapPath("App_Data/db1.mdb");
                conn1.Open();            string strCre = " create table " + TextBox2.Text + "(书名 varchar(50),图书编号 int primary key,作者 varchar(30),出版社 varchar(50),图书售价 money,简介 varchar(100))";            OleDbCommand com1 = new OleDbCommand(strCre, conn1);            com1.ExecuteNonQuery();
                conn1.Close();
                Session["dingdan"] = TextBox2.Text;
            }
        }
    }
      

  8.   

    我补充个可能,ACCESS文件写入权限。
      

  9.   

    你的那种写法明显是连接orcle数据库的  你的 连接 字符串 不对