本文介绍了如果是IsPostback,我会收到大胆的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Oracle中拥有表格
I have table in Oracle
Create Table (
USERNAME VARCHAR2(70),
PASSWORD VARCHAR2(50),
EMAIL VARCHAR2(30))
namespace abc
{
public partial class Test1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//OracleConnection ora = new OracleConnection(conn);
//ora.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SID=glmjoy)));User Id=glmjoy;Password=glmjoy;";
//string qry = "insert into test1 (username) values (@txtusername)";
//OracleCommand cmd=new OracleCommand(qry,ora);
//cmd.Parameters.Add("username", txtusername.Text);
//ora.Open();
//cmd.ExecuteScalar();
//ora.Close();
//-----------------
if (!IsPostBack == true)
{ inert();
} ----------- I am getting error here
protected void inert()
{ //If a PostBack occured, then handle your Oracle Database call
string conn = "";
//Create an OracleDatabase object
OracleConnection ora = new OracleConnection(conn);
{
//Open your connection
conn.Open();
//Build your actual statement (example demonstrating parameters)
string sql = "INSERT INTO test1 (username) VALUES (@username)";
//Builds your command that will be executed
OracleCommand cmd = new OracleCommand(sql, conn);
//Populates your Parameters (examples)
cmd.Parameters.AddWithValue("@Username", txtusername.Text);
//Execute your command
cmd.ExecuteNonQuery();
}
}
}
}
推荐答案
namespace abc
{
public partial class Test1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
inert();
}
} // This is missing.
protected void inert()
{
// All the function codes
}
}
}
这篇关于如果是IsPostback,我会收到大胆的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!