作者在 2010-06-14 23:24:39 发布以下内容
using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
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;
using System.Data.OleDb;
using System.Configuration;
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;
public partial class _Default : System.Web.UI.Page
{
OleDbConnection conn = new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
protected void Page_Load(object sender, EventArgs e)
{
{
OleDbConnection conn = new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
OleDbDataReader dr;
int i;
conn.ConnectionString = "ProVider=Microsoft.jet.OLEDB.4.0;Data Source=" + Server.MapPath("../信息1/销售信息.mdb");
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from 职工表 ";
conn.Open();
dr = cmd.ExecuteReader();
Response.Write("<table border='1' width='600px'>");
while (dr.Read())
{
Response.Write("<tr>");
for (i = 0; i < dr.FieldCount; i++)
{
Response.Write("<td>" + dr.GetValue(i) + "</td>");
}
Response.Write("</tr>");
}
Response.Write("</table>");
dr.Close();
conn.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
conn.ConnectionString = "ProVider=Microsoft.jet.OLEDB.4.0;Data Source=" + Server.MapPath("../信息1/销售信息.mdb");
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Update 职工表 set 工资=工资*1.05";
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
protected void Button3_Click(object sender, EventArgs e)
{
conn.ConnectionString = "ProVider=Microsoft.jet.OLEDB.4.0;Data Source=" + Server.MapPath("../信息1/销售信息.mdb");
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
//string s1=TextBox1.Text.Trim();
cmd.CommandText = "delete from 职工表 where 姓名='" + TextBox1.Text + "'";
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
protected void Button4_Click(object sender, EventArgs e)
{
OleDbDataReader dr;
conn.ConnectionString = "ProVider=Microsoft.jet.OLEDB.4.0;Data Source=" + Server.MapPath("../信息1/销售信息.mdb");
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT 工资 FROM 职工表 WHERE 姓名='" + TextBox2.Text + "'";
conn.Open();
dr = cmd.ExecuteReader();
Label5.Text =dr.VisibleFieldCount.ToString();//这里不能实现请指点下
conn.Close();
}
protected void Button5_Click(object sender, EventArgs e)
{
conn.ConnectionString = "ProVider=Microsoft.jet.OLEDB.4.0;Data Source=" + Server.MapPath("../信息1/销售信息.mdb");
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
string s1, s2, s3, s4;
s1 = TextBox3.Text.Trim();
s2 = TextBox4.Text.Trim();
s3 = TextBox5.Text.Trim();
s4 = TextBox6.Text.Trim();
cmd.CommandText = "insert into 职工表(职工号,姓名,职务,工资) values('" + s1 + "','" + s2 + "','" + s3 + "','" + s4 + "')";
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
OleDbDataReader dr;
int i;
conn.ConnectionString = "ProVider=Microsoft.jet.OLEDB.4.0;Data Source=" + Server.MapPath("../信息1/销售信息.mdb");
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from 职工表 ";
conn.Open();
dr = cmd.ExecuteReader();
Response.Write("<table border='1' width='600px'>");
while (dr.Read())
{
Response.Write("<tr>");
for (i = 0; i < dr.FieldCount; i++)
{
Response.Write("<td>" + dr.GetValue(i) + "</td>");
}
Response.Write("</tr>");
}
Response.Write("</table>");
dr.Close();
conn.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
conn.ConnectionString = "ProVider=Microsoft.jet.OLEDB.4.0;Data Source=" + Server.MapPath("../信息1/销售信息.mdb");
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Update 职工表 set 工资=工资*1.05";
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
protected void Button3_Click(object sender, EventArgs e)
{
conn.ConnectionString = "ProVider=Microsoft.jet.OLEDB.4.0;Data Source=" + Server.MapPath("../信息1/销售信息.mdb");
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
//string s1=TextBox1.Text.Trim();
cmd.CommandText = "delete from 职工表 where 姓名='" + TextBox1.Text + "'";
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
protected void Button4_Click(object sender, EventArgs e)
{
OleDbDataReader dr;
conn.ConnectionString = "ProVider=Microsoft.jet.OLEDB.4.0;Data Source=" + Server.MapPath("../信息1/销售信息.mdb");
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT 工资 FROM 职工表 WHERE 姓名='" + TextBox2.Text + "'";
conn.Open();
dr = cmd.ExecuteReader();
Label5.Text =dr.VisibleFieldCount.ToString();//这里不能实现请指点下
conn.Close();
}
protected void Button5_Click(object sender, EventArgs e)
{
conn.ConnectionString = "ProVider=Microsoft.jet.OLEDB.4.0;Data Source=" + Server.MapPath("../信息1/销售信息.mdb");
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
string s1, s2, s3, s4;
s1 = TextBox3.Text.Trim();
s2 = TextBox4.Text.Trim();
s3 = TextBox5.Text.Trim();
s4 = TextBox6.Text.Trim();
cmd.CommandText = "insert into 职工表(职工号,姓名,职务,工资) values('" + s1 + "','" + s2 + "','" + s3 + "','" + s4 + "')";
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
}
本程序还有点问题,希望各位指正!