아래의 간단한 예문 참고하세요~
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Oracle.DataAccess.Client;
using System.Web.Security;
.......................
.......................
protected void btnWrite_Click(object sender, EventArgs e)
{
string insertString = "INSERT INTO aspboard (no, writer, password, title, content, ";
insertString += "ref_no, reply_order, depth, read_count, del_flag, reg_date) ";
insertString += "VALUES(aspboard_seq.nextval, :writer, :password, :title, :content, 0, 0, 0, 0, ";
insertString += "'N', sysdate)";
string updateString = "UPDATE aspboard SET ref_no = no WHERE ref_no = 0";
string hashedPassword =
FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "sha1");
DBUtil conn = new DBUtil();
OracleCommand cmd = new OracleCommand(insertString, conn.GetConn());
cmd.Parameters.Add(":writer", OracleDbType.Varchar2, 50).Value = txtWriter.Text;
cmd.Parameters.Add(":password", OracleDbType.Varchar2, 15).Value = txtPassword.Text;
cmd.Parameters.Add(":title", OracleDbType.Varchar2, 50).Value = txtTitle.Text;
cmd.Parameters.Add(":content", OracleDbType.Varchar2, 4000).Value = txtContent.Text;
try
{
cmd.ExecuteNonQuery();
}
catch (Exception error)
{
Response.Write(error.ToString());
}
finally
{
conn.Close();
}
Response.Redirect("List.aspx");
}
댓글 없음:
댓글 쓰기