📄 test.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
namespace comm
{
/// <summary>
/// TEST 的摘要说明。
/// </summary>
public class TEST : System.Web.UI.Page
{
//// protected IBM.Data.DB2.DB2Connection db2Connection1;
//// protected IBM.Data.DB2.DB2DataAdapter db2DataAdapter1;
//// protected IBM.Data.DB2.DB2Command db2SelectCommand1;
//// protected IBM.Data.DB2.DB2Command db2InsertCommand1;
//// protected IBM.Data.DB2.DB2Command db2UpdateCommand1;
//// protected IBM.Data.DB2.DB2Command db2DeleteCommand1;
// protected System.Web.UI.WebControls.TextBox TXT_LINE;
//
private void Page_Load(object sender, System.EventArgs e)
{
// // 在此处放置用户代码以初始化页面
// this.TXT_LINE.Text ="ljdlkdj"+"\r\n"+"kjdljdljd";
// //this.db2Connection1 =new IBM.Data.DB2.DB2Connection();
// this.TXT_LINE.Text=this.db2Connection1.ConnectionString;
this.DataGrid1.Visible=false;
}
//
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
// private void InitializeComponent()
// {
// this.db2Connection1 = new IBM.Data.DB2.DB2Connection();
// this.db2DataAdapter1 = new IBM.Data.DB2.DB2DataAdapter();
// this.db2SelectCommand1 = new IBM.Data.DB2.DB2Command();
// this.db2InsertCommand1 = new IBM.Data.DB2.DB2Command();
// this.db2UpdateCommand1 = new IBM.Data.DB2.DB2Command();
// this.db2DeleteCommand1 = new IBM.Data.DB2.DB2Command();
// //
// // db2Connection1
// //
// this.db2Connection1.ClientAccountingInformation = "";
// this.db2Connection1.ClientApplicationInformation = "";
// this.db2Connection1.ClientUser = "";
// this.db2Connection1.ClientWorkStation = "";
// this.db2Connection1.ConnectionString = "database=OMDB;Connect Timeout=30;user Id=YAOP;";
// //
// // db2DataAdapter1
// //
// this.db2DataAdapter1.DeleteCommand = this.db2DeleteCommand1;
// this.db2DataAdapter1.InsertCommand = this.db2InsertCommand1;
// this.db2DataAdapter1.SelectCommand = this.db2SelectCommand1;
// this.db2DataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
// new System.Data.Common.DataTableMapping("Table", "OM_MENU_TABLE", new System.Data.Common.DataColumnMapping[] {
// new System.Data.Common.DataColumnMapping("ID", "ID"),
// new System.Data.Common.DataColumnMapping("CAPTION", "CAPTION"),
// new System.Data.Common.DataColumnMapping("NAME", "NAME"),
// new System.Data.Common.DataColumnMapping("INDEX", "INDEX"),
// new System.Data.Common.DataColumnMapping("PARENT", "PARENT"),
// new System.Data.Common.DataColumnMapping("URL", "URL")})});
// this.db2DataAdapter1.UpdateCommand = this.db2UpdateCommand1;
// //
// // db2SelectCommand1
// //
// this.db2SelectCommand1.CommandText = "SELECT ID, CAPTION, NAME, INDEX, PARENT, URL FROM YAOP.OM_MENU_TABLE";
// this.db2SelectCommand1.Connection = this.db2Connection1;
// //
// // db2InsertCommand1
// //
// this.db2InsertCommand1.CommandText = "INSERT INTO YAOP.OM_MENU_TABLE (CAPTION, NAME, INDEX, PARENT, URL) VALUES (?, ?," +
// " ?, ?, ?)";
// this.db2InsertCommand1.Connection = this.db2Connection1;
// this.db2InsertCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("CAPTION", IBM.Data.DB2.DB2Type.VarChar, 20, "CAPTION"));
// this.db2InsertCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("NAME", IBM.Data.DB2.DB2Type.VarChar, 10, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "NAME", System.Data.DataRowVersion.Current, null));
// this.db2InsertCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("INDEX", IBM.Data.DB2.DB2Type.BigInt, 8, "INDEX"));
// this.db2InsertCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("PARENT", IBM.Data.DB2.DB2Type.BigInt, 8, "PARENT"));
// this.db2InsertCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("URL", IBM.Data.DB2.DB2Type.VarChar, 1000, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "URL", System.Data.DataRowVersion.Current, null));
// //
// // db2UpdateCommand1
// //
// this.db2UpdateCommand1.CommandText = @"UPDATE YAOP.OM_MENU_TABLE SET CAPTION = ?, NAME = ?, INDEX = ?, PARENT = ?, URL = ? WHERE (ID = ?) AND (CAPTION = ?) AND (NAME = ? OR CAST(? as VARCHAR ( 10 )) IS NULL AND NAME IS NULL) AND (INDEX = ?) AND (PARENT = ?) AND (URL = ? OR CAST(? as VARCHAR ( 1000 )) IS NULL AND URL IS NULL) ";
// this.db2UpdateCommand1.Connection = this.db2Connection1;
// this.db2UpdateCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("CAPTION", IBM.Data.DB2.DB2Type.VarChar, 20, "CAPTION"));
// this.db2UpdateCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("NAME", IBM.Data.DB2.DB2Type.VarChar, 10, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "NAME", System.Data.DataRowVersion.Current, null));
// this.db2UpdateCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("INDEX", IBM.Data.DB2.DB2Type.BigInt, 8, "INDEX"));
// this.db2UpdateCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("PARENT", IBM.Data.DB2.DB2Type.BigInt, 8, "PARENT"));
// this.db2UpdateCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("URL", IBM.Data.DB2.DB2Type.VarChar, 1000, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "URL", System.Data.DataRowVersion.Current, null));
// this.db2UpdateCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_ID", IBM.Data.DB2.DB2Type.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null));
// this.db2UpdateCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_CAPTION", IBM.Data.DB2.DB2Type.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CAPTION", System.Data.DataRowVersion.Original, null));
// this.db2UpdateCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_NAME", IBM.Data.DB2.DB2Type.VarChar, 10, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "NAME", System.Data.DataRowVersion.Original, null));
// this.db2UpdateCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_NAME1", IBM.Data.DB2.DB2Type.VarChar, 10, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "NAME", System.Data.DataRowVersion.Original, null));
// this.db2UpdateCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_INDEX", IBM.Data.DB2.DB2Type.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "INDEX", System.Data.DataRowVersion.Original, null));
// this.db2UpdateCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_PARENT", IBM.Data.DB2.DB2Type.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "PARENT", System.Data.DataRowVersion.Original, null));
// this.db2UpdateCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_URL", IBM.Data.DB2.DB2Type.VarChar, 1000, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "URL", System.Data.DataRowVersion.Original, null));
// this.db2UpdateCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_URL1", IBM.Data.DB2.DB2Type.VarChar, 1000, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "URL", System.Data.DataRowVersion.Original, null));
// //
// // db2DeleteCommand1
// //
// this.db2DeleteCommand1.CommandText = "DELETE FROM YAOP.OM_MENU_TABLE WHERE (ID = ?) AND (CAPTION = ?) AND (NAME = ? " +
// "OR CAST(? as VARCHAR ( 10 )) IS NULL AND NAME IS NULL) AND (INDEX = ?) AND (PAR" +
// "ENT = ?) AND (URL = ? OR CAST(? as VARCHAR ( 1000 )) IS NULL AND URL IS NULL) " +
// "";
// this.db2DeleteCommand1.Connection = this.db2Connection1;
// this.db2DeleteCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_ID", IBM.Data.DB2.DB2Type.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ID", System.Data.DataRowVersion.Original, null));
// this.db2DeleteCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_CAPTION", IBM.Data.DB2.DB2Type.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CAPTION", System.Data.DataRowVersion.Original, null));
// this.db2DeleteCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_NAME", IBM.Data.DB2.DB2Type.VarChar, 10, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "NAME", System.Data.DataRowVersion.Original, null));
// this.db2DeleteCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_NAME1", IBM.Data.DB2.DB2Type.VarChar, 10, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "NAME", System.Data.DataRowVersion.Original, null));
// this.db2DeleteCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_INDEX", IBM.Data.DB2.DB2Type.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "INDEX", System.Data.DataRowVersion.Original, null));
// this.db2DeleteCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_PARENT", IBM.Data.DB2.DB2Type.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "PARENT", System.Data.DataRowVersion.Original, null));
// this.db2DeleteCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_URL", IBM.Data.DB2.DB2Type.VarChar, 1000, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "URL", System.Data.DataRowVersion.Original, null));
// this.db2DeleteCommand1.Parameters.Add(new IBM.Data.DB2.DB2Parameter("ORIGINAL_URL1", IBM.Data.DB2.DB2Type.VarChar, 1000, System.Data.ParameterDirection.Input, true, ((System.Byte)(0)), ((System.Byte)(0)), "URL", System.Data.DataRowVersion.Original, null));
//
// }
#endregion
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
include.Db db=new comm.include.Db();
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
}
private void Button1_Click(object sender, System.EventArgs e)
{
db.DataBase=ConfigurationSettings.AppSettings["main_db"];
// db.IP=ConfigurationSettings.AppSettings["IP"];
db.IP ="";
db.Usr =ConfigurationSettings.AppSettings["usr"];
db.Pwd =ConfigurationSettings.AppSettings["pwd"];
string sql=this.TextBox1.Text.Trim();
if(sql.Substring(0,6).ToUpper()=="SELECT")
{
DataSet ds=new DataSet();
ds=db.GetDataSet(sql);
try
{
if(ds==null)
{
db.Msgbox("语句错误","",this.Page);
return;
}
}
catch(Exception ce)
{
db.Msgbox(ce.Message.ToString(),"语句错误",this.Page);
return;
}
this.DataGrid1.DataSource=ds;
this.DataGrid1.DataBind();
this.DataGrid1.Visible =true;
}
else
{
try
{
db.ExecSQL(sql);
}
catch(Exception ce)
{
db.Msgbox(ce.Message.ToString(),"语句错误",this.Page);
return;
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -