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();
}
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();
}
解决方案 »
- 本版新新手,下载了动易的BizIdea,运行了出现如下错误,怎么解决?
- 新年第一问:SQL数据库导入菜鸟问题!
- asp.net2005中有没有类似textarea的控件?
- 插入数据错误:当 IDENTITY_INSERT 设置为 OFF 时,不能向表 'ProjBaseInfo' 中的标识列插入显式值。
- 我就想要一个带搜索功能的C#写的网站,要多少分自己写,可以另开帖给分
- 高分求救:关于windows服务+消息队列,紧急!
- 我的 World Wide Web Publishing 服务由于“错误3:系统找不到指定的路径”而无法启动,IIS就等于没用,怎么办?
- ASP.Net中,XML格式的相对路径怎样设置?
- web程序中,点击打印按钮后,要等很长时间才有响应,如何在页面上做一个等待的提示框??
- gridview隐藏某一列,但是提示索引超出范围 必须为非负值并小于集合大小
- SelfWebService引用那个命名空间
- 为什么这个更新语句就是更新不了呢?
对于 UPDATE、INSERT 和 DELETE 语句,返回值为该命令所影响的行数。如果正在执行插入或更新操作的表上存在触发器,则返回值包括受插入或更新操作影响的行数以及受一个或多个触发器影响的行数。对于所有其他类型的语句,返回值为 -1。如果发生回滚,返回值也为 -1。
同意,输出sql,先在数据中执行看看
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;
}
}
}
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;
}
}
}