报错,帮我看看
code:
<%@ Page Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
// Insert page code here
//
void Btn_Add_Click(object sender, EventArgs e) {
string ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;"+
"Data Source=C:\\NaiYuan\\Db\\BigShop.mdb";
string CommandString = "Select * from Branch";
OleDbConnection MyConn = new OleDbConnection(ConnectionString);
OleDbDataAdapter MyAdapter = new OleDbDataAdapter(CommandString,MyConn);
DataSet MyData = new DataSet();
MyAdapter.Fill(MyData,"Branch");
//DataGrid1.DataSource = MyData.Tables["Branch"];
//DataGrid1.DataBind();
//add block
DataTable Branch_Table;
DataRow newRow;
Branch_Table = MyData.Tables["Branch"];
newRow = Branch_Table.NewRow();
newRow["Shop_Name"] = Tb_Name.Text;
newRow["Shop_Location"] = Tb_Location.Text;
Branch_Table.Rows.Add(newRow);
OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(MyAdapter);
MyAdapter.UpdateCommand = commandBuilder.GetUpdateCommand();
MyAdapter.InsertCommand = commandBuilder.GetInsertCommand();
MyAdapter.DeleteCommand = commandBuilder.GetDeleteCommand();
MyAdapter.Update(MyData,"Branch");
DataGrid1.DataSource = MyData.Tables["Branch"];
DataGrid1.DataBind();
}
//del block
void Btn_Del_Click(object sender, EventArgs e) {
Branch_Table.Rows[Branch_Table.Rows.Count-3].Delete();
MyAdapter.Update(MyData,"Branch");
DataGrid1.DataSource = MyData.Tables["Branch"];
DataGrid1.DataBind();
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:Label id="Label1" runat="server">Shop Name</asp:Label>
<asp:TextBox id="Tb_Name" runat="server"></asp:TextBox>
<br />
<asp:Label id="Label2" runat="server">Shop Location</asp:Label>
<!-- Insert content here -->
<asp:TextBox id="Tb_Location" runat="server"></asp:TextBox>
<br />
<asp:Button id="Btn_Add" onclick="Btn_Add_Click" runat="server" Text="Add"></asp:Button>
<asp:Button id="Btn_Del" onclick="Btn_Del_Click" runat="server" Text="Del"></asp:Button>
<asp:Button id="Btn_Edit" runat="server" Text="Edit"></asp:Button>
<asp:Button id="Btn_Search" runat="server" Text="Search"></asp:Button>
<br />
<asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>
</form>
</body>
</html>
//error message
erver Error in '/' Application.
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'Branch_Table' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 37: //del block
Line 38: void Btn_Del_Click(object sender, EventArgs e) {
Line 39: Branch_Table.Rows[Branch_Table.Rows.Count-3].Delete();
Line 40: MyAdapter.Update(MyData,"Branch");
Line 41: DataGrid1.DataSource = MyData.Tables["Branch"];
Source File: NaiYuan\EBike\Branch.aspx Line: 39