易截截图软件、单文件、免安装、纯绿色、仅160KB

ASP.NET2.0连接ORACLE解决方案

界面: Default.aspx
 
界面上添加的控件:
两个TextBox: tEmail(用于输入用户email),tPassword(用于输入注册密码)
一个Button: bReg
一个Label: lLable(用于注册成功后显示应答)
Demo的代码: Default.aspx.cs
我们先把数据的连接字符串写在Web.config里:
<appSettings>
<add key="oracleconn" value="User ID=用户名;Password=密码;Data Source=数据库服务名;"/>
</appSettings>
下面是Demo的源代码:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OracleClient; //添加OracleClient的引用
public partial class _Default : System.Web.UI.Page
{
public System.Data.OracleClient.OracleConnection objConn; //声明一个OracleConnection对象
public System.Data.OracleClient.OracleCommand objCmd; //声明一个OracleCommand对象
protected void Page_Load(object sender, EventArgs e)
{
lLable.Text = "";
string strcon = System.Configuration.ConfigurationManager.AppSettings["oracleconn"];
//从Web.config 文件里调用数据库连接字符串
objConn = new OracleConnection(strcon);
}
protected void bReg_Click(object sender, EventArgs e)
{
string strSQL = "INSERT INTO TEMP(EMAIL,PASSWORD) values ('";
strSQL+=tEmail.Text.Replace("'","''").ToString()+"','";
strSQL+=tPassword.Text.Replace("'","''").ToString()+"')";
objCmd = new OracleCommand(strSQL, objConn);
objConn.Open();
objCmd.ExecuteNonQuery();
objConn.Close();
lLable.Text = "注册成功,您的邮件地址是:"+tEmail.Text.ToString();
}
}
注意:
其实直接写上面的代码会出不少错误的,要做两个工作才可以。
1. ASP.NET2.0里默认不能直接添加using System.Data.OracleClient;需要在填加引用的.NET组件框里选择System.Data.OracleClient添加后才能用。
2. 在ASP.NET1.1中调用Web.config中的数据库连接字符串时使用语句System.Configuration.ConfigurationSettings.AppSettings["oracle"];,在2.0里须要使用System.Configuration.ConfigurationManager.AppSettings


相关文档:

DML Error Logging in Oracle 10g

DML Error Logging in Oracle 10g
主要在于使用DBMS_ERRLOG.create_error_log 这个包来跟踪dml错误信息
SQL> CREATE TABLE source (
2 id NUMBER(10) NOT NULL,
3 code VARCHAR2(10),
4 description VARCHAR2(50),
5 CONSTRAINT source_pk PRIMARY KEY (id)
6 );
表已创建。
SQL> DECLARE
2 TYPE t_tab IS ......

ORACLE概要文件

记得以前上OCP课程的时候那个老师教我们使用PROFILE来限制用户的一些操作,那个时候估计是老师偷懒吧,所有实验都是通过OEM的形式来操作,根本不会涉及到命令行。
平时在学习ORACLE的过程中好像也很少碰到关于PROFILE的问题,今天逛一个朋友的BLOG的时候发现这篇文章,觉得挺好的,内容不多,简洁明了,好歹也算是个命令行 ......

小布老师oracle视频讲座笔记(二)

Oracle Process Structure
Oracle takes advantage of various types of processes:
 —User process: Started at the time a database user requests connection to the Oracle server
  —Server process: Connects to the Oracle instance and is started when a user establishes a session
& ......

ORACLE 外键约束对NULL的处理

刚才在网上搜这个问题的时候搜到ITPUB上yangtingkun博客里的一篇文章,写的挺好的,自己复制了一下他的实验过程,加了点步骤验证了自己的想法,也解决了疑问。
前面写过一篇文章,介绍过唯一约束的情况下,Oracle处理NULL的特点。简单的说,就是如果多个列构成了唯一,且其中包含一个以上的NULL,那么Oracle会要求不为NULL ......

什么是Asp.Net应用程序

 ASP.NET defines an application as the sum of all files, pages, handlers, modules, and executable code that can be invoked or run in the scope of a given virtual directory (and its subdirectories) on a Web application server. For example, an "order" application might be published in the "/order ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号