分享
 
 
 

insert into data.mdb

王朝other·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

<%@ Import Namespace="System.Data" %>

<%@ Import Namespace="System.Data.OleDb" %>

<html>

<script language="C#" runat="server">

protected void Page_Load(Object Src, EventArgs E)

{

string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";

strConnection += @"Data Source=\\genfs1\www11\etning\xml\Northwind.mdb";

if (!IsPostBack)

BindGrid();

}

public void AddEmployees_Click(Object sender, EventArgs E)

{

if (EmployeeID.Value == "" || LastName.Value == "" || FirstName.Value == "" || HomePhone.Value == "")

{

Message.InnerHtml = "eer:“EmployeeID”、“LastName”OR“HomePhone”no hhhhhhong";

Message.Style["color"] = "red";

BindGrid();

return;

}

String insertstr = "insert into Employees (EmployeeID, LastName, FirstName, HomePhone, Address, City, Country, Notes, PostalCode) values (@EmployeeID, @LastName, @FirstName, @HomePhone, @Address, @City, @Country, @Notes, @PostalCode)";

OleDbCommand strCommand = new OleDbCommand(insertstr,strConnection);

int cmdresults = 0;

OleDbCommand2.CommandText = "NewAuthor";

OleDbCommand2.CommandType = CommandType.StoredProcedure;

OleDbCommand2.Parameters["EmployeeID"].Value = TextBox1.Text;

OleDbCommand2.Parameters["LastName"].Value = TextBox2.Text;

OleDbCommand2.Parameters["FirstName"].Value = TextBox3.Text;

OleDbCommand2.Parameters["HomePhone"].Value = TextBox4.Text;

OleDbCommand2.Parameters["Address"].Value = TextBox5.Text;

OleDbCommand2.Parameters["City"].Value = TextBox6.Text;

OleDbCommand2.Parameters["Country"].Value = TextBox7.Text;

OleDbCommand2.Parameters["Notes"].Value = TextBox8.Text;

OleDbCommand2.Parameters["PostalCode"].Value = CheckBox1.Checked;

OleDbConnection2.Open();

try

{

cmdresults = OleDbCommand2.ExecuteNonQuery();

}

catch (Exception ex)

{

MessageBox.Show("Failed to execute command, err = " + ex.Message);

}

OleDbConnection2.Close();

MessageBox.Show("Number of records inserted = " + cmdresults.ToString());

myCommand.Connection.Close();

BindGrid();

}

public void BindGrid()

{

string strSQL = "SELECT * FROM Employees";

DataSet objDataSet = new DataSet();

OleDbConnection objConnection = new OleDbConnection(strConnection);

OleDbDataAdapter objAdapter = new OleDbDataAdapter(strSQL, objConnection);

objAdapter.Fill(objDataSet, "Employees");

DataView objDataView = new DataView(objDataSet.Tables["Employees"]);

MyDataGrid.DataSource=objDataView;

MyDataGrid.DataBind();

}

</script>

<body style="font: 10.5pt 宋体">

<form runat="server">

<h3><font face="宋体">插入数据行</font></h3>

<table width="95%">

<tr>

<td valign="top">

<ASP:DataGrid id="MyDataGrid" runat="server"

Width="700"

BackColor="#ccccff"

BorderColor="black"

ShowFooter="false"

CellPadding=3

CellSpacing="0"

Font-Name="宋体"

Font-Size="8pt"

HeaderStyle-BackColor="#aaaadd"

EnableViewState="false"

/>

</td>

<td valign="top">

<table style="font: 9pt 宋体">

<tr>

<td colspan="2" bgcolor="#aaaadd" style="font:10.5pt 宋体">添加新作者:</td>

</tr>

<tr>

<td nowrap>作者 ID:</td>

<td><input type="text" id="EmployeeID" value="000-00-0000" runat="server"></td>

</tr>

<tr>

<td nowrap>姓氏:</td>

<td><input type="text" id="LastName" value="Doe" runat="server"></td>

</tr>

<tr nowrap>

<td>名字:</td>

<td><input type="text" id="FirstName" value="John" runat="server"></td>

</tr>

<tr>

<td>电话:</td>

<td><input type="text" id="HomePhone" value="808 555-5555" runat="server"></td>

</tr>

<tr>

<td>地址:</td>

<td><input type="text" id="Address" value="One Microsoft Way" runat="server"></td>

</tr>

<tr>

<td>城市:</td>

<td><input type="text" id="City" value="Redmond" runat="server"></td>

</tr>

<tr>

<td>州:</td>

<td>

<select id="Country" runat="server">

<option>CA</option>

<option>IN</option>

<option>KS</option>

<option>MD</option>

<option>MI</option>

<option>OR</option>

<option>TN</option>

<option>UT</option>

</select>

</td>

</tr>

<tr>

<td nowrap>邮政编码:</td>

<td><input type="text" id="Notes" value="98005" runat="server"></td>

</tr>

<tr>

<td>PostalCode:</td>

<td>

<select id="PostalCode" runat="server">

<option value="0">假</option>

<option value="1">真</option>

</select>

</td>

</tr>

<tr>

<td></td>

<td style="padding-top:15">

<input type="submit" OnServerClick="AddEmployees_Click" value="添加作者" runat="server">

</td>

</tr>

<tr>

<td colspan="2" style="padding-top:15" align="center">

<span id="Message" EnableViewState="false" style="font: arial 11pt;" runat="server"/>

</td>

</tr>

</table>

</td>

</tr>

</table>

</form>

</body>

</html>

里面有部分错误,请各位高手指点,谢谢!

连接到演示

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有