易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

ORACLE SAVE EXCEPTION 子句

今天在一个帖子里看到shiyiwan的回帖中提及到了两个自己以前没见过的概念,save exception和dml error logging。上网搜了搜相关内容,看了看大概明白意思,不过在实际运用中还是没怎么用过。保存下来,以后用的到的话方便查阅。
这一篇是关于save exception的,另外一篇dml error logging的参见如下链接
http://blog.csdn ......

小布老师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
& ......

asp.net客户端脚本调用webservice

 由于 asp.net ajax 封装了很多很好的方法,所以使用这个框架调用webwervice变的非常简单。
第一步
webservice 类的方法需要有scriptService的  attribute.
 namespace ServiceTest
{
/// <summary>
///WebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tem ......

什么是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 ......

什么是ASP.NET

 What is ASP.NET
ASP.NET is a unified Web development model that includes the services necessary for you to build enterprise-class Web applications with a minimum of coding. ASP.NET is part of the .NET Framework, and when coding ASP.NET applications you have access to classes in the .NET Frame ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号