无为清净楼资源网 Design By www.qnjia.com
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class html_Test_Execl : System.Web.UI.Page
......{
static string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath("~/html/") + "new.xls;Extended Properties=Excel 8.0;";
protected void Page_Load(object sender, EventArgs e)
......{
}
protected void btnADONET_CreateExecle_Click(object sender, EventArgs e)
......{
OleDbConnection cn = new OleDbConnection( connectionString );
cn.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = cn;
cmd.CommandText = "create table myTable(firstName char(255),lastName char(255))";
cmd.ExecuteNonQuery();
cmd.CommandText = "insert into myTable (firstName,lastName) values('liao','haibing')";
cmd.ExecuteNonQuery();
cmd.CommandText = "insert into myTable(firstName,lastName) values('廖','海兵')";
cmd.ExecuteNonQuery();
cmd.CommandText = "create table myTable2(姓名 char(255) , 住址 char(255))";
cmd.ExecuteNonQuery();
cn.Close();
}
protected void btnShowExecl_Content_Click(object sender, EventArgs e)
......{
ShowExeclContent();
}
private void ShowExeclContent()
......{
OleDbConnection cn = new OleDbConnection(connectionString);
OleDbDataAdapter dda = new OleDbDataAdapter("select * from [myTable]", cn);
DataSet ds = new DataSet();
dda.Fill(ds, "myTable");
DataGrid1.DataSource = ds.Tables["myTable"].DefaultView;
DataGrid1.DataBind();
}
protected void btnInsertExecl_Click(object sender, EventArgs e)
......{
InsertExeclDate();
ShowExeclContent();
}
private void InsertExeclDate()
......{
string executeString = "insert into myTable(firstName,lastName)values('" + this.txtFirstName.Text.Trim() + "','" + txtLastName.Text.Trim() + "')";
this.upDate_Insert_Delete_Operator(executeString);
}
protected void btnUpdateSelect_Click(object sender, EventArgs e)
......{
upDateSelect(this.txtFirstName.Text.Trim(), this.txtLastName.Text.Trim());
ShowExeclContent();
}
private void upDateSelect(string firstName,string lastName)
......{
string executeString = "update myTable set lastName = '" + lastName + "' where firstName = '" + firstName + "'";
this.upDate_Insert_Delete_Operator(executeString);
}
/**//**//**////删除操作进行不了,提示ISAM 不支持在链接表中删除数据。 不知道有没有什么办法可以解决这个问题
protected void btnDelete_Click(object sender, EventArgs e)
......{
Delete(this.txtFirstName.Text.Trim());
ShowExeclContent();
}
private void Delete(string firstName)
......{
string executeString = "delete from myTable where firstName = '" + firstName + "'";
this.upDate_Insert_Delete_Operator(executeString);
}
private void upDate_Insert_Delete_Operator(string executeString)
......{
OleDbConnection cn = new OleDbConnection(connectionString);
cn.Open();
OleDbCommand cmd = new OleDbCommand(executeString, cn);
cmd.ExecuteNonQuery();
cn.Close();
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class html_Test_Execl : System.Web.UI.Page
......{
static string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath("~/html/") + "new.xls;Extended Properties=Excel 8.0;";
protected void Page_Load(object sender, EventArgs e)
......{
}
protected void btnADONET_CreateExecle_Click(object sender, EventArgs e)
......{
OleDbConnection cn = new OleDbConnection( connectionString );
cn.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = cn;
cmd.CommandText = "create table myTable(firstName char(255),lastName char(255))";
cmd.ExecuteNonQuery();
cmd.CommandText = "insert into myTable (firstName,lastName) values('liao','haibing')";
cmd.ExecuteNonQuery();
cmd.CommandText = "insert into myTable(firstName,lastName) values('廖','海兵')";
cmd.ExecuteNonQuery();
cmd.CommandText = "create table myTable2(姓名 char(255) , 住址 char(255))";
cmd.ExecuteNonQuery();
cn.Close();
}
protected void btnShowExecl_Content_Click(object sender, EventArgs e)
......{
ShowExeclContent();
}
private void ShowExeclContent()
......{
OleDbConnection cn = new OleDbConnection(connectionString);
OleDbDataAdapter dda = new OleDbDataAdapter("select * from [myTable]", cn);
DataSet ds = new DataSet();
dda.Fill(ds, "myTable");
DataGrid1.DataSource = ds.Tables["myTable"].DefaultView;
DataGrid1.DataBind();
}
protected void btnInsertExecl_Click(object sender, EventArgs e)
......{
InsertExeclDate();
ShowExeclContent();
}
private void InsertExeclDate()
......{
string executeString = "insert into myTable(firstName,lastName)values('" + this.txtFirstName.Text.Trim() + "','" + txtLastName.Text.Trim() + "')";
this.upDate_Insert_Delete_Operator(executeString);
}
protected void btnUpdateSelect_Click(object sender, EventArgs e)
......{
upDateSelect(this.txtFirstName.Text.Trim(), this.txtLastName.Text.Trim());
ShowExeclContent();
}
private void upDateSelect(string firstName,string lastName)
......{
string executeString = "update myTable set lastName = '" + lastName + "' where firstName = '" + firstName + "'";
this.upDate_Insert_Delete_Operator(executeString);
}
/**//**//**////删除操作进行不了,提示ISAM 不支持在链接表中删除数据。 不知道有没有什么办法可以解决这个问题
protected void btnDelete_Click(object sender, EventArgs e)
......{
Delete(this.txtFirstName.Text.Trim());
ShowExeclContent();
}
private void Delete(string firstName)
......{
string executeString = "delete from myTable where firstName = '" + firstName + "'";
this.upDate_Insert_Delete_Operator(executeString);
}
private void upDate_Insert_Delete_Operator(string executeString)
......{
OleDbConnection cn = new OleDbConnection(connectionString);
cn.Open();
OleDbCommand cmd = new OleDbCommand(executeString, cn);
cmd.ExecuteNonQuery();
cn.Close();
}
}
标签:
asp.net,Execl,添加
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年11月18日
2024年11月18日
- APM亚流新世代《一起冒险》[320K/MP3][68.66MB]
- FIM《天伦乐》(DaydreamsAndLullabies)24K金碟[WAV+CUE]
- 【雨果唱片】中国管弦乐《鹿回头》
- 【雨果唱片】中国管弦乐《鹿回头》WAV
- APM亚流新世代《一起冒险》[FLAC/分轨][106.77MB]
- 崔健《飞狗》律冻文化[WAV+CUE][1.1G]
- 罗志祥《舞状元 (Explicit)》[320K/MP3][66.77MB]
- 尤雅.1997-幽雅精粹2CD【南方】【WAV+CUE】
- 张惠妹.2007-STAR(引进版)【EMI百代】【WAV+CUE】
- 群星.2008-LOVE情歌集VOL.8【正东】【WAV+CUE】
- 罗志祥《舞状元 (Explicit)》[FLAC/分轨][360.76MB]
- Tank《我不伟大,至少我能改变我。》[320K/MP3][160.41MB]
- Tank《我不伟大,至少我能改变我。》[FLAC/分轨][236.89MB]
- CD圣经推荐-夏韶声《谙2》SACD-ISO
- 钟镇涛-《百分百钟镇涛》首批限量版SACD-ISO