脑袋疼,感觉就是执行了,没有commit。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Oracle.ManagedDataAccess.Client;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Oracle.ManagedDataAccess.Types;
using Oracle.ManagedDataAccess.Client.SqlGen;
using System.Windows.Forms;
using System.Data.OracleClient;
public partial class his_device : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Panel1.Visible == true)
{
Button1.Text = "Show Search Panel";
Panel1.Visible = false;
}
else
{
Button1.Text = "Hide Search Panel";
Panel1.Visible = true;
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
//this.HISI_DEVICE.SelectCommand="SELECT * FROM SCC_B2B.HIS_DEVICE WHERE DEVICE_NAME LIKE '" + this.TxtDevice.Text + "%'";
//this.GridView1.DataBind();
using (Oracle.ManagedDataAccess.Client.OracleConnection conn = new Oracle.ManagedDataAccess.Client.OracleConnection())
{
conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str_sql = "SELECT * FROM SCC_B2B.HIS_DEVICE";
TxtDevice.Text.Replace("'", "");
TxtDevice.Text.Replace(";", "");
if (!TxtDevice.Text.Equals(""))
{
str_sql = str_sql + " WHERE DEVICE_NAME LIKE '" + TxtDevice.Text + "%'";
}
Oracle.ManagedDataAccess.Client.OracleDataAdapter da = new Oracle.ManagedDataAccess.Client.OracleDataAdapter(str_sql, conn);
DataSet ds = new DataSet();
da.Fill(ds, "Device");
GridView1.DataSource = ds;
GridView1.DataBind();
da.Dispose();
ds.Dispose();
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void GridView1_PageIndexChanging(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("../Default.aspx");
}
protected void btnInsert_Click1(object sender, EventArgs e)
{
using (Oracle.ManagedDataAccess.Client.OracleConnection conn = new Oracle.ManagedDataAccess.Client.OracleConnection())
{
conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
Oracle.ManagedDataAccess.Client.OracleCommand cmd = new Oracle.ManagedDataAccess.Client.OracleCommand();
conn.Open();
string sql = ("insert into SCC_B2B.HIS_DEVICE (device_name,device_type) values( '"+TxtDevice.Text+"','"+TxtFactory.Text+"')");
conn.Close();
if (TxtDevice.Text == "")
{
MessageBox.Show("Device_name cannot be null", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (TxtFactory.Text == "")
{
Response.Write("Device_type cannot be null");
}
else
{
Response.Write("数据添加成功!");
}
}
}
}
protected void btnDelete_Click(object sender, EventArgs e)
{
using (Oracle.ManagedDataAccess.Client.OracleConnection conn = new Oracle.ManagedDataAccess.Client.OracleConnection())
{
Oracle.ManagedDataAccess.Client.OracleCommand cmd = new Oracle.ManagedDataAccess.Client.OracleCommand();
conn.Open();
string sql = ("insert into SCC_B2B.HIS_DEVICE (device_name,device_type) values( '" + TxtDevice.Text + "','" + TxtFactory.Text + "')");
int ret = (int)cmd.ExecuteNonQuery();
conn.Close();
if (TxtDevice.Text == "")
{
MessageBox.Show("Device_name cannot be null", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (TxtFactory.Text == "")
{
MessageBox.Show("Device_type cannot be null", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (ret > 0)
{
MessageBox.Show("数据添加成功!");
}
else
{
MessageBox.Show("数据添加失败!");
}
}
}
}
}
}