asp.net+C#中,如何打开access数据库呢?在asp.net中又如何去显示和修改数据库? 我也是新手建议看ms的quickstart我觉得不错 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就你说的功能VB.NET和C#没什么大区别 private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 //System.String strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\del_hbj\\db\\db1.mdb;Persist Security Info=False;Jet OLEDB:Database Password=111222"; System.String strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("db\\db1.mdb")+";Persist Security Info=False;Jet OLEDB:Database Password=111222"; if(!this.IsPostBack) { OleDbConnection conn=new OleDbConnection(strcon); conn.Open(); string strsql; if(TextBox1.Text=="") { strsql="select *from 支票数据"; ListBox1.Visible=false; } else { strsql="select *from 支票数据 where 用途 like '%"+TextBox1.Text.Trim()+"%'"; ListBox1.Visible=true; } System.Data.DataSet ds=new DataSet(); System.Data.OleDb.OleDbDataAdapter da=new OleDbDataAdapter(strsql,conn); System.Data.DataTable dt=new DataTable(); da.Fill(dt); da.Fill(ds,"支票数据"); DataGrid1.DataSource=ds; DataGrid1.DataBind(); ListBox1.DataSource=dt; ListBox1.DataTextField="用途"; ListBox1.DataBind(); DropDownList1.DataSource=ds; DropDownList1.DataTextField="收款人"; DropDownList1.DataBind(); if (ListBox1.Items.Count!=0) { Response.Write(ListBox1.Items[0].Value); } } } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.Button1.Click += new System.EventHandler(this.Button1_Click); this.ListBox1.SelectedIndexChanged += new System.EventHandler(this.ListBox1_SelectedIndexChanged_1); this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click); this.Repeater1.ItemCommand += new System.Web.UI.WebControls.RepeaterCommandEventHandler(this.Repeater1_ItemCommand); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e) { } private void Button1_Click(object sender, System.EventArgs e) { System.String strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("db\\db1.mdb")+";Persist Security Info=False;Jet OLEDB:Database Password=111222"; OleDbConnection conn=new OleDbConnection(strcon); conn.Open(); ListBox1.Visible=true; string strsql; if(TextBox1.Text=="") { strsql="select *from 支票数据"; } else { strsql="select *from 支票数据 where 用途 like '%"+TextBox1.Text.Trim()+"%'"; ListBox1.Visible=true; } System.Data.DataSet ds=new DataSet(); System.Data.OleDb.OleDbDataAdapter da=new OleDbDataAdapter(strsql,conn); System.Data.DataTable dt=new DataTable(); da.Fill(dt); da.Fill(ds,"支票数据"); ListBox1.DataSource=dt; ListBox1.DataTextField="用途"; ListBox1.DataBind(); // TextBox1.Text=ListBox1.Items[2].Text; //TextBox1.Text=ListBox1.Items[ListBox1.SelectedIndex].Text; } private void LinkButton1_Click(object sender, System.EventArgs e) { Response.Redirect ("Webchuanzhi.aspx?name="+TextBox1.Text); } private void ListBox1_SelectedIndexChanged_1(object sender, System.EventArgs e) { TextBox1.Text=ListBox1.Items[ListBox1.SelectedIndex].Text; } sql算法求解~~~~~~~~~~~~~~~~~~~~~~~~~~~上午面试,考虑了很久都没思路 谁做过paypal支付。 框架之间的跳转 DropDownList与CheckBoxList选择性地绑定数据问题 (SQL) 『200分』急,用戶控件執行父容器用戶控件的一個方法? 任何将普通图片的格式转换为xps格式 求助,在.net中使用自带验证控件无效的问题 关于DataReader连接问题 多处定义的问题? 怎样更改web自定义控件的图标 如何给动态生成的textbox控件的width,height付值? cookies的迷惑!!!
{
// 在此处放置用户代码以初始化页面
//System.String strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\del_hbj\\db\\db1.mdb;Persist Security Info=False;Jet OLEDB:Database Password=111222";
System.String strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("db\\db1.mdb")+";Persist Security Info=False;Jet OLEDB:Database Password=111222";
if(!this.IsPostBack)
{
OleDbConnection conn=new OleDbConnection(strcon);
conn.Open();
string strsql;
if(TextBox1.Text=="")
{
strsql="select *from 支票数据";
ListBox1.Visible=false;
}
else
{
strsql="select *from 支票数据 where 用途 like '%"+TextBox1.Text.Trim()+"%'";
ListBox1.Visible=true;
} System.Data.DataSet ds=new DataSet();
System.Data.OleDb.OleDbDataAdapter da=new OleDbDataAdapter(strsql,conn);
System.Data.DataTable dt=new DataTable();
da.Fill(dt);
da.Fill(ds,"支票数据");
DataGrid1.DataSource=ds;
DataGrid1.DataBind();
ListBox1.DataSource=dt;
ListBox1.DataTextField="用途";
ListBox1.DataBind();
DropDownList1.DataSource=ds;
DropDownList1.DataTextField="收款人";
DropDownList1.DataBind();
if (ListBox1.Items.Count!=0)
{
Response.Write(ListBox1.Items[0].Value);
}
}
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.ListBox1.SelectedIndexChanged += new System.EventHandler(this.ListBox1_SelectedIndexChanged_1);
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.Repeater1.ItemCommand += new System.Web.UI.WebControls.RepeaterCommandEventHandler(this.Repeater1_ItemCommand);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
} private void Button1_Click(object sender, System.EventArgs e)
{
System.String strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("db\\db1.mdb")+";Persist Security Info=False;Jet OLEDB:Database Password=111222";
OleDbConnection conn=new OleDbConnection(strcon);
conn.Open();
ListBox1.Visible=true;
string strsql;
if(TextBox1.Text=="")
{
strsql="select *from 支票数据";
}
else
{
strsql="select *from 支票数据 where 用途 like '%"+TextBox1.Text.Trim()+"%'";
ListBox1.Visible=true;
} System.Data.DataSet ds=new DataSet();
System.Data.OleDb.OleDbDataAdapter da=new OleDbDataAdapter(strsql,conn);
System.Data.DataTable dt=new DataTable();
da.Fill(dt);
da.Fill(ds,"支票数据");
ListBox1.DataSource=dt;
ListBox1.DataTextField="用途";
ListBox1.DataBind();
// TextBox1.Text=ListBox1.Items[2].Text;
//TextBox1.Text=ListBox1.Items[ListBox1.SelectedIndex].Text;
}
private void LinkButton1_Click(object sender, System.EventArgs e)
{
Response.Redirect ("Webchuanzhi.aspx?name="+TextBox1.Text);
} private void ListBox1_SelectedIndexChanged_1(object sender, System.EventArgs e)
{
TextBox1.Text=ListBox1.Items[ListBox1.SelectedIndex].Text;
}