aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ora con.aspx.cs" Inherits="ora_con" %>
.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data;
using System.Data.OracleClient;
public partial class ora_con : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnora_Click(object sender, EventArgs e)
{
//try
//{
//use your own userid,password and datasorce
string Constring;
Constring = WebConfigurationManager.ConnectionStrings["QuickStarts Instance"].ConnectionString;
OracleConnection con = new OracleConnection(Constring);
con.Open();
OracleCommand cmd = con.CreateCommand();
cmd.CommandText = "CREATE TABLE con(id varchar2(20),name varchar2(50), 'DATE (DATE)')"; // i dont know hw to create date datatype here
cmd.ExecuteNonQuery();
Response.Write("");
//}
//catch (Exception)
//{
// Response.Write("");
//}
}
protected void Button2_Click(object sender, EventArgs e)
{
{
string Constring, query;
Constring = WebConfigurationManager.ConnectionStrings["QuickStarts Instance"].ConnectionString;
OracleConnection con = new OracleConnection(Constring);
con.Open();
query = "SELECT name,id FROM con where id = '" + TextBox3.Text.Trim() + "'";
OracleCommand command = new OracleCommand(query, con);
OracleDataReader reader = command.ExecuteReader();
reader.Read();
TextBox2.Text = reader[0].ToString();
TextBox1.Text = reader[1].ToString();
reader.Close();
con.Close();
}
}
protected void ddlcons(object sender, EventArgs e)
{
if (ddlcon.SelectedValue.ToString() == "1")
{
TextBox1.Text = "";
TextBox2.Text = "";
// TextBox3.Text = "";
}
else
{
Console.WriteLine("No Changes");
}
}
protected void Button3_Click(object sender, EventArgs e)
{
{
string Constring;
Constring = WebConfigurationManager.ConnectionStrings["QuickStarts Instance"].ConnectionString;
OracleConnection con = new OracleConnection(Constring);
con.Open();
string str = "insert into con (id) values ('" + TextBox1.Text + "')";//,'" + TextBox2.Text + "')"; // i dont know how to insert date value
OracleCommand cmd = new OracleCommand(str, con);
cmd.ExecuteNonQuery();
con.Close();
Response.Write("Inserted");
}
}
}
Posted Aug 2, 2013, 5:10 AM
createdDate = DateTime.Parse(txtdate.text);
If you know date format in db side,
createdDate = DateTime.ParseExact(txtdate.text, format,CultureInfo.InvariantCulture);
vidhyaPosted Aug 2, 2013, 4:48 AM
try like this,
OracleDateTime ordate;
If not
can u mention what error you are getting?
Rajesh BPosted Aug 2, 2013, 4:41 AM
vidhyaPosted Aug 2, 2013, 4:22 AM
Rajesh BPosted Aug 1, 2013, 8:18 AM
Rajesh BPosted Aug 1, 2013, 5:58 AM
Rajesh BPosted Aug 1, 2013, 5:55 AM
Posted Aug 1, 2013, 5:46 AM
Data is a keyword, so i renamed to createdDate.
During insertion, what are the values you're sending to oracle db especially for the date column? Where & How are you entering date values?
Rajesh BPosted Aug 1, 2013, 3:34 AM
Posted Aug 1, 2013, 3:12 AM