/*
* Created on 2005-12-17
*/
package com.taxware.zdsy_server.oracledal;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import oracle.jdbc.OracleTypes;
import oracle.jdbc.rowset.OracleCachedRowSet;
/**
* @author hucl
*
*
*/
public abstract class OracleHelper {
/**
* @param String cmdtext,SQL语句
* @param OracleParameter[] parms,参数集合
* @return int,SQL语句影响的行数
*/
public static int executeSql(String cmdtext, OracleParameter[] parms)
throws Exception {
PreparedStatement pstmt = null;
Connection conn = null;
try {
conn = ConnectMgr.getConnect();
pstmt = conn.prepareStatement(cmdtext);
prepareCommand(pstmt, parms);
return pstmt.executeUpdate();
}
catch (Exception e) {
throw new Exception("executeNonQuery方法出错:" + e.getMessage());
}
finally {
try {
if (pstmt != null)
pstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("执行executeNonQuery方法出错:" + e.getMessage());
}
}
}
/**
*
* @param cmdtext
* @param parms
* @return int[] 多条SQL的影响行数
* @throws Exception
*/
public static int[] executeSqlBatch(String cmdtext, Object[] parms)
throws Exception {
PreparedStatement pstmt = null;
Connection conn = null;
try {
conn = ConnectMgr.getConnect();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(cmdtext);
prepareCommand(pstmt, parms);
int[] ret = pstmt.executeBatch();
conn.commit();
return ret;
}
catch (Exception e) {
conn.rollback();
throw new Exception("执行executeSqlBatch方法出错:" + e.getMessage());
}
finally {
try {
if (pstmt != null)
pstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("执行executeSqlBatch方法出错:" + e.getMessage());
}
}
}
/**
*
* @param cmdtext
* @param parms
* @return ResultSet
* @throws Exception
*/
public static ResultSet executeSqlResultSet(String cmdtext,
OracleParameter[] parms) throws Exception {
PreparedStatement pstmt = null;
Connection conn = null;
try {
conn = ConnectMgr.getConnect();
pstmt = conn.prepareStatement(cmdtext);
prepareCommand(pstmt, parms);
return pstmt.executeQuery();
}
catch (Exception e) {
throw new Exception("executeSqlResultSet方法出错:" + e.getMessage());
}
finally {
try {
if (pstmt != null)
pstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("executeSqlResultSet方法出错:" + e.getMessage());
}
}
}
/**
*
* @param sptext 存储过程语句
* @param parms OracleParameter[]
* @return boolean 成功为true,失败为false
* @throws Exception
*/
public static boolean executeProcedure(String sptext, OracleParameter[] parms)
throws Exception {
Connection conn = null;
CallableStatement cstmt = null;
try {
conn = ConnectMgr.getConnect();
conn.setAutoCommit(true);
cstmt = conn.prepareCall(sptext);
prepareCommand(cstmt, parms);
return cstmt.execute();
}
catch (Exception e) {
throw new Exception("executeProcedure方法出错:" + e.getMessage());
}
finally {
try {
if (cstmt != null)
cstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("执行executeProcedure方法出错:" + e.getMessage());
}
}
}
/**
*
* @param sptext 存储过程语句
* @param parms OracleParameter[]
* @return Object[] 出参的结果
* @throws Exception
*/
public static Object[] executeProcedureObject(String sptext,
OracleParameter[] parms) throws Exception {
Connection conn = null;
CallableStatement cstmt = null;
try {
conn = ConnectMgr.getConnect();
cstmt = conn.prepareCall(sptext);
//应用参数
prepareCommand(cstmt, parms);
cstmt.execute();
int count = parms.length;
Object[] result = new Object[count];
for (int i = 0; i < count; i++) {
//判断是否有出参
if (parms[i].getInorout().compareToIgnoreCase("OUT") >= 0) {
/*判断是否是结果集,如果不是结果集,直接加到数组中;
*如果是结果集执行else下的语句,把结果集写到OracleCachedRowSet中,ResultSet的关闭不会受到影响
*原因:如果直接传ResultSet,
*在执行finally语句时会连同ResultSet一同关闭,
*在其他地方没法正确读出结果集
*/
if (parms[i].getType() != OracleTypes.CURSOR) {
result[i] = cstmt.getObject(parms[i].getIndex());
}
else {
OracleCachedRowSet ocrs = new OracleCachedRowSet();
ResultSet rs = null;
//取出ResutltSet对象
rs = (ResultSet)(cstmt.getObject(parms[i].getIndex()));
//写到OracleCachedRowSet对象
ocrs.populate(rs);
//关闭ResultSet
rs.close();
//把对象添加到数组
result[i] = (Object)ocrs;
}
//判断结束
}
else {
; //如果不是出参,执行下次循环
}
}
return result;
}
catch (Exception e) {
throw new Exception("executeProcedureObject方法出错:" + e.getMessage());
}
finally {
try {
if (cstmt != null)
cstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("executeProcedureObject方法出错:" + e.getMessage());
}
}
}
/**
*
* @param cmdtext SQL语句
* @param name 列名
* @param parms OracleParameter[]
* @return Object
* @throws Exception
*/
public static Object executeSqlObject(String cmdtext, String name,
OracleParameter[] parms) throws Exception {
PreparedStatement pstmt = null;
Connection conn = null;
ResultSet rs = null;
try {
conn = ConnectMgr.getConnect();
pstmt = conn.prepareStatement(cmdtext);
prepareCommand(pstmt, parms);
rs = pstmt.executeQuery();
if (rs.next()) {
return rs.getObject(name);
}
else {
return null;
}
}
catch (Exception e) {
throw new Exception("executeSqlObject方法出错:" + e.getMessage());
}
finally {
try {
if (rs != null)
rs.close();
if (pstmt != null)
pstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("executeSqlObject方法出错:" + e.getMessage());
}
}
}
/**
*
* @param cmdtext SQL语句
* @param index 列名索引
* @param parms OracleParameter[]
* @return Object
* @throws Exception
*/
public static Object executeSqlObject(String cmdtext, int index,
OracleParameter[] parms) throws Exception {
PreparedStatement pstmt = null;
Connection conn = null;
ResultSet rs = null;
try {
conn = ConnectMgr.getConnect();
pstmt = conn.prepareStatement(cmdtext);
prepareCommand(pstmt, parms);
rs = pstmt.executeQuery();
if (rs.next()) {
return rs.getObject(index);
}
else {
return null;
}
}
catch (Exception e) {
throw new Exception("executeSqlObject方法出错:" + e.getMessage());
}
finally {
try {
if (rs != null)
rs.close();
if (pstmt != null)
pstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("executeSqlObject方法出错:" + e.getMessage());
}
}
}
/**
* @param pstmt
* @param cmdtext
* @param parms Object[]
* @throws Exception
*/
private static void prepareCommand(PreparedStatement pstmt, Object[] parms)
throws Exception {
int count = parms.length;
for (int i = 0; i < count; i++) {
OracleParameter[] op;
op = (OracleParameter[]) parms[i];
prepareCommand(pstmt, op);
pstmt.addBatch();
}
}
/**
*
* @param pstmt
* @param parms
* @throws Exception
*/
private static void prepareCommand(PreparedStatement pstmt,
OracleParameter[] parms) throws Exception {
if (parms == null) {
return;
}
int count;
count = parms.length;
for (int i = 0; i < count; i++) {
OracleParameter op = new OracleParameter();
op = parms[i];
pstmt.setObject(op.getIndex(), op.getValue());
}
}
/**
*
* @param cstmt
* @param parms
* @throws Exception
*/
private static void prepareCommand(CallableStatement cstmt,
OracleParameter[] parms) throws Exception {
if (parms == null) {
return;
}
int count;
count = parms.length;
try {
for (int i = 0; i < count; i++) {
OracleParameter op = new OracleParameter();
op = parms[i];
if (op.getInorout().compareToIgnoreCase("OUT") >= 0)
cstmt.registerOutParameter(op.getIndex(), op.getType());
else
cstmt.setObject(op.getIndex(), op.getValue());
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
public static void main(String[] args) throws Exception {
/*
//测试1
OracleParameter[] parms;
parms = new OracleParameter[] {
new OracleParameter(1,"4")
};
OracleHelper.executeNonQuery(1,"insert into SYS_CONFIG(name) values(?)",parms);
//测试2
Object[] parms;
OracleParameter[] op1;
op1 = new OracleParameter[] {
new OracleParameter(1,"4")
};
OracleParameter[] op2;
op2 = new OracleParameter[] {
new OracleParameter(1,"5")
};
OracleParameter[] op3;
op3 = new OracleParameter[] {
new OracleParameter(1,"6")
};
parms = new Object[] {
op1,op2,op3
};
String sql = "insert into SYS_CONFIG(NAME) VALUES(?)";
OracleHelper.executeNonQuery(sql,parms);
//测试3
Object o = OracleHelper.executeSqlObject("select name from SYS_CONFIG ","name",null);
System.out.println(o);
//测试4
Object[] o;
OracleParameter[] parms;
parms = new OracleParameter[] {
new OracleParameter(1, "1"),
new OracleParameter(2, java.sql.Types.VARCHAR)
};
o = OracleHelper.executeProcedureObject(
"{call USP_SYS_CONFIG_GETVALUE(?,?)}", parms);
if (o != null) {
System.out.println(o[1].toString());
}
else {
System.out.println("null");
}
*/
}
}
* Created on 2005-12-17
*/
package com.taxware.zdsy_server.oracledal;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import oracle.jdbc.OracleTypes;
import oracle.jdbc.rowset.OracleCachedRowSet;
/**
* @author hucl
*
*
*/
public abstract class OracleHelper {
/**
* @param String cmdtext,SQL语句
* @param OracleParameter[] parms,参数集合
* @return int,SQL语句影响的行数
*/
public static int executeSql(String cmdtext, OracleParameter[] parms)
throws Exception {
PreparedStatement pstmt = null;
Connection conn = null;
try {
conn = ConnectMgr.getConnect();
pstmt = conn.prepareStatement(cmdtext);
prepareCommand(pstmt, parms);
return pstmt.executeUpdate();
}
catch (Exception e) {
throw new Exception("executeNonQuery方法出错:" + e.getMessage());
}
finally {
try {
if (pstmt != null)
pstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("执行executeNonQuery方法出错:" + e.getMessage());
}
}
}
/**
*
* @param cmdtext
* @param parms
* @return int[] 多条SQL的影响行数
* @throws Exception
*/
public static int[] executeSqlBatch(String cmdtext, Object[] parms)
throws Exception {
PreparedStatement pstmt = null;
Connection conn = null;
try {
conn = ConnectMgr.getConnect();
conn.setAutoCommit(false);
pstmt = conn.prepareStatement(cmdtext);
prepareCommand(pstmt, parms);
int[] ret = pstmt.executeBatch();
conn.commit();
return ret;
}
catch (Exception e) {
conn.rollback();
throw new Exception("执行executeSqlBatch方法出错:" + e.getMessage());
}
finally {
try {
if (pstmt != null)
pstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("执行executeSqlBatch方法出错:" + e.getMessage());
}
}
}
/**
*
* @param cmdtext
* @param parms
* @return ResultSet
* @throws Exception
*/
public static ResultSet executeSqlResultSet(String cmdtext,
OracleParameter[] parms) throws Exception {
PreparedStatement pstmt = null;
Connection conn = null;
try {
conn = ConnectMgr.getConnect();
pstmt = conn.prepareStatement(cmdtext);
prepareCommand(pstmt, parms);
return pstmt.executeQuery();
}
catch (Exception e) {
throw new Exception("executeSqlResultSet方法出错:" + e.getMessage());
}
finally {
try {
if (pstmt != null)
pstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("executeSqlResultSet方法出错:" + e.getMessage());
}
}
}
/**
*
* @param sptext 存储过程语句
* @param parms OracleParameter[]
* @return boolean 成功为true,失败为false
* @throws Exception
*/
public static boolean executeProcedure(String sptext, OracleParameter[] parms)
throws Exception {
Connection conn = null;
CallableStatement cstmt = null;
try {
conn = ConnectMgr.getConnect();
conn.setAutoCommit(true);
cstmt = conn.prepareCall(sptext);
prepareCommand(cstmt, parms);
return cstmt.execute();
}
catch (Exception e) {
throw new Exception("executeProcedure方法出错:" + e.getMessage());
}
finally {
try {
if (cstmt != null)
cstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("执行executeProcedure方法出错:" + e.getMessage());
}
}
}
/**
*
* @param sptext 存储过程语句
* @param parms OracleParameter[]
* @return Object[] 出参的结果
* @throws Exception
*/
public static Object[] executeProcedureObject(String sptext,
OracleParameter[] parms) throws Exception {
Connection conn = null;
CallableStatement cstmt = null;
try {
conn = ConnectMgr.getConnect();
cstmt = conn.prepareCall(sptext);
//应用参数
prepareCommand(cstmt, parms);
cstmt.execute();
int count = parms.length;
Object[] result = new Object[count];
for (int i = 0; i < count; i++) {
//判断是否有出参
if (parms[i].getInorout().compareToIgnoreCase("OUT") >= 0) {
/*判断是否是结果集,如果不是结果集,直接加到数组中;
*如果是结果集执行else下的语句,把结果集写到OracleCachedRowSet中,ResultSet的关闭不会受到影响
*原因:如果直接传ResultSet,
*在执行finally语句时会连同ResultSet一同关闭,
*在其他地方没法正确读出结果集
*/
if (parms[i].getType() != OracleTypes.CURSOR) {
result[i] = cstmt.getObject(parms[i].getIndex());
}
else {
OracleCachedRowSet ocrs = new OracleCachedRowSet();
ResultSet rs = null;
//取出ResutltSet对象
rs = (ResultSet)(cstmt.getObject(parms[i].getIndex()));
//写到OracleCachedRowSet对象
ocrs.populate(rs);
//关闭ResultSet
rs.close();
//把对象添加到数组
result[i] = (Object)ocrs;
}
//判断结束
}
else {
; //如果不是出参,执行下次循环
}
}
return result;
}
catch (Exception e) {
throw new Exception("executeProcedureObject方法出错:" + e.getMessage());
}
finally {
try {
if (cstmt != null)
cstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("executeProcedureObject方法出错:" + e.getMessage());
}
}
}
/**
*
* @param cmdtext SQL语句
* @param name 列名
* @param parms OracleParameter[]
* @return Object
* @throws Exception
*/
public static Object executeSqlObject(String cmdtext, String name,
OracleParameter[] parms) throws Exception {
PreparedStatement pstmt = null;
Connection conn = null;
ResultSet rs = null;
try {
conn = ConnectMgr.getConnect();
pstmt = conn.prepareStatement(cmdtext);
prepareCommand(pstmt, parms);
rs = pstmt.executeQuery();
if (rs.next()) {
return rs.getObject(name);
}
else {
return null;
}
}
catch (Exception e) {
throw new Exception("executeSqlObject方法出错:" + e.getMessage());
}
finally {
try {
if (rs != null)
rs.close();
if (pstmt != null)
pstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("executeSqlObject方法出错:" + e.getMessage());
}
}
}
/**
*
* @param cmdtext SQL语句
* @param index 列名索引
* @param parms OracleParameter[]
* @return Object
* @throws Exception
*/
public static Object executeSqlObject(String cmdtext, int index,
OracleParameter[] parms) throws Exception {
PreparedStatement pstmt = null;
Connection conn = null;
ResultSet rs = null;
try {
conn = ConnectMgr.getConnect();
pstmt = conn.prepareStatement(cmdtext);
prepareCommand(pstmt, parms);
rs = pstmt.executeQuery();
if (rs.next()) {
return rs.getObject(index);
}
else {
return null;
}
}
catch (Exception e) {
throw new Exception("executeSqlObject方法出错:" + e.getMessage());
}
finally {
try {
if (rs != null)
rs.close();
if (pstmt != null)
pstmt.close();
if (conn != null)
conn.close();
}
catch (Exception e) {
throw new Exception("executeSqlObject方法出错:" + e.getMessage());
}
}
}
/**
* @param pstmt
* @param cmdtext
* @param parms Object[]
* @throws Exception
*/
private static void prepareCommand(PreparedStatement pstmt, Object[] parms)
throws Exception {
int count = parms.length;
for (int i = 0; i < count; i++) {
OracleParameter[] op;
op = (OracleParameter[]) parms[i];
prepareCommand(pstmt, op);
pstmt.addBatch();
}
}
/**
*
* @param pstmt
* @param parms
* @throws Exception
*/
private static void prepareCommand(PreparedStatement pstmt,
OracleParameter[] parms) throws Exception {
if (parms == null) {
return;
}
int count;
count = parms.length;
for (int i = 0; i < count; i++) {
OracleParameter op = new OracleParameter();
op = parms[i];
pstmt.setObject(op.getIndex(), op.getValue());
}
}
/**
*
* @param cstmt
* @param parms
* @throws Exception
*/
private static void prepareCommand(CallableStatement cstmt,
OracleParameter[] parms) throws Exception {
if (parms == null) {
return;
}
int count;
count = parms.length;
try {
for (int i = 0; i < count; i++) {
OracleParameter op = new OracleParameter();
op = parms[i];
if (op.getInorout().compareToIgnoreCase("OUT") >= 0)
cstmt.registerOutParameter(op.getIndex(), op.getType());
else
cstmt.setObject(op.getIndex(), op.getValue());
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
public static void main(String[] args) throws Exception {
/*
//测试1
OracleParameter[] parms;
parms = new OracleParameter[] {
new OracleParameter(1,"4")
};
OracleHelper.executeNonQuery(1,"insert into SYS_CONFIG(name) values(?)",parms);
//测试2
Object[] parms;
OracleParameter[] op1;
op1 = new OracleParameter[] {
new OracleParameter(1,"4")
};
OracleParameter[] op2;
op2 = new OracleParameter[] {
new OracleParameter(1,"5")
};
OracleParameter[] op3;
op3 = new OracleParameter[] {
new OracleParameter(1,"6")
};
parms = new Object[] {
op1,op2,op3
};
String sql = "insert into SYS_CONFIG(NAME) VALUES(?)";
OracleHelper.executeNonQuery(sql,parms);
//测试3
Object o = OracleHelper.executeSqlObject("select name from SYS_CONFIG ","name",null);
System.out.println(o);
//测试4
Object[] o;
OracleParameter[] parms;
parms = new OracleParameter[] {
new OracleParameter(1, "1"),
new OracleParameter(2, java.sql.Types.VARCHAR)
};
o = OracleHelper.executeProcedureObject(
"{call USP_SYS_CONFIG_GETVALUE(?,?)}", parms);
if (o != null) {
System.out.println(o[1].toString());
}
else {
System.out.println("null");
}
*/
}
}
相关推荐
标题 "VB.NET SQLHelper DLL 包" 涉及的核心技术是使用VB.NET语言开发一个SQLHelper类库,该类库通常是为了简化数据库操作而设计的。SQLHelper类可以帮助开发者更方便、高效地执行SQL语句,减少重复代码,提高代码的...
用了很多年的asp.net SQLHelper,封装的方法绝对够用,工作中一直在用
在.NET框架中,ADO.NET是用于访问数据库的主要技术,它提供了与各种数据库系统交互的接口。在实际开发中,为了提高代码的复用性和可维护性,开发者常常会自封一个SqlHelper类来简化数据库操作。这个SqlHelper类通常...
在C#编程环境中,Oracle数据库的连接和操作通常需要通过ADO.NET或者其他第三方库来实现。在本场景中,我们关注的是一个名为"C#中oracle连接数据库的封装类"的主题,这个主题涉及到创建一个名为`DbHelperOra.cs`的类...
在Java编程中,连接Oracle数据库是一项常见的任务,用于执行SQL查询、更新和其他数据库操作。`sqlHelper`类是一个自定义的工具类,旨在简化这个过程,提供一个方便、高效的接口来处理数据库交互。本篇文章将深入探讨...
在.NET Framework中,连接并操作数据库是开发过程中非常常见的需求之一。通过提供的描述与部分代码内容,我们可以深入了解如何使用.NET Framework的数据提供程序进行数据库的操作,尤其是如何返回单行或多行多列的...
ADO.NET中简单实用的三种方法,并将其进行封装,便于操作者进行开发与使用。
在.NET框架中,SqlHelper是一个常用的辅助类库,它简化了与SQL Server数据库的交互,尤其是在执行SQL命令时。这个编程小实例展示了如何利用C++.NET来利用SqlHelper查询数据库记录。下面,我们将深入探讨这一主题,...
在.NET框架中,SqlHelper是一个常用的辅助类,用于简化与SQL Server数据库的交互。这个编程小实例主要展示了如何使用C++ .NET来实现SqlHelper,从而便捷地向数据库添加新记录。下面我们将深入探讨这个话题。 首先,...
这个类库的主要目标是提高代码的可读性、可维护性和安全性,通过封装数据库连接、事务处理以及参数化查询等常见操作,帮助开发者避免SQL注入等安全问题。 SqlHelper类库通常包含以下功能: 1. **ExecuteNonQuery**...
- 提高代码可读性和可维护性:通过封装数据库操作,代码更简洁,易于理解和维护。 - 数据访问的安全性:通过参数化查询,降低了SQL注入的风险。 - 性能优化:利用ADO.NET连接池,减少创建和销毁连接的开销。 缺点:...
.NET 数据库访问组件是开发人员在构建应用程序时用于与各种数据库进行交互的工具。这些组件通常简化了数据查询、插入、更新和删除等操作,提高了开发效率并降低了代码的复杂性。XML操作则是另一种常见的数据处理方式...
C# 链接Oracle数据库操作类 SqlHelper.cs,.NET3.0以上即可使用,涵盖了oracle数据库的增删改查操作,并可调用存储过程,因是源码,可根据自己实际需要再修改,灵活性较大
通过jdbc的方式访问数据库: 1.程序是整理的韩顺平oracle教学视频中的一个例子。 2.假设本机安装了oracle...4.程序对数据库操作进行了一定程度的封装,封装函数放在SQLHelper类中,在TestOracleCrud中对函数进行测试。
asp.net 连接sql server 工具类,我也不想要资源分数,但没有0分选项
SqlHelper和OracleHelper是.NET开发中常用的两个辅助类库,主要用于简化数据库操作,尤其是SQL Server和Oracle数据库的CRUD(创建、读取、更新、删除)操作。在.NET框架下,开发者经常使用ADO.NET来与数据库进行交互...
VB.NET实现SqlHelper数据库操作组件,组件中包含数据库操作方法。SqlHelper用于简化你重复的去写那些数据库连接(SqlConnection),SqlCommand,SqlDataReader等等。SqlHelper 封装过后通常是只需要给方法传入一些参数...
Java通过JDBC(Java Database Connectivity)和ODBC(Open Database Connectivity)来连接Oracle数据库是两种常见的数据访问方式。本文将详细介绍这两种方法,并提供相关的技术知识。 首先,JDBC是Java平台的标准...
总之,SQLHelper.cs作为Asp.Net中的数据库辅助类,通过封装常见的数据库操作,降低了开发难度,提高了代码复用性。理解和熟练使用SQLHelper.cs,能够有效地提升Asp.Net项目中的数据访问层的开发效率。
ADO.NET是微软.NET框架下的一种数据访问技术,用于与各种关系型数据库进行交互,包括SQL Server、Oracle、MySQL等。这个实例着重展示了如何利用ADO.NET进行数据库的基本操作,如连接数据库、执行SQL语句、处理结果集...