<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OracleClient"%>
<%@ Page Language="C#" Debug="true" %>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
//Sample1();
Sample2();
}
void Sample1()
{
System.Data.OracleClient.OracleConnection objConn;
System.Data.OracleClient.OracleCommand objCmd;
String strConnString,strSQL;
strConnString = "Data Source=TCDB;User Id=myuser;Password=mypassword;";
objConn = new System.Data.OracleClient.OracleConnection(strConnString);
objConn.Open();
strSQL = "INSERT INTO customer (CustomerID,Name,Email,CountryCode,Budget,Used) " +
"VALUES ('C005','Weerachai Nukitram','[email protected]','TH','2000000','1000000')";
objCmd = new System.Data.OracleClient.OracleCommand();
objCmd.Connection = objConn;
objCmd.CommandType = CommandType.Text;
objCmd.CommandText = strSQL;
objCmd.ExecuteNonQuery();
lblText.Text = lblText.Text + "- Record Inserted";
objCmd = null;
objConn.Close();
objConn = null;
}
void Sample2()
{
System.Data.OracleClient.OracleConnection objConn;
System.Data.OracleClient.OracleCommand objCmd;
String strConnString,strSQL;
strConnString = "Data Source=TCDB;User Id=myuser;Password=mypassword;";
objConn = new System.Data.OracleClient.OracleConnection(strConnString);
objConn.Open();
strSQL = "INSERT INTO customer (CustomerID,Name,Email,CountryCode,Budget,Used) " +
"VALUES ('C005','Weerachai Nukitram','[email protected]','TH','2000000','1000000')";
objCmd = new System.Data.OracleClient.OracleCommand(strSQL,objConn);
try
{
objCmd.ExecuteNonQuery();
lblText.Text = lblText.Text + "- Record Inserted";
}
catch(Exception ex)
{
lblText.Text = lblText.Text + "<br> - Record not insert was (" + ex.Message + ")";
}
objCmd = null;
objConn.Close();
objConn = null;
}
</script>
<html>
<head>
<title>ThaiCreate.Com ASP.NET - System.Data.OracleClient</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label id="lblText" runat="Server"></asp:Label>
</form>
</body>
</html>