ADO.NET的一段数据库操作代码
时间:2010-10-12 来源:牛小浩
int currentIndex = 0;
int pageSize = 10;
//System.Data.OracleClient.OracleConnection connection = new SqlConnection("Data Source=ORCL_100.0.3.10;User Id=btvaudit2;Password=btvaudit2;");
//connection.Open();
DbProviderFactory dbfactory = DbProviderFactories.GetFactory("System.Data.OracleClient");
DbConnection dbconn = dbfactory.CreateConnection();
dbconn.ConnectionString = "Data Source=ORCL_100.0.3.10;User Id=btvaudit2;Password=btvaudit2;";
string orderSQL = "SELECT * FROM a_wsinterfaceinfo order by requesttime desc";
DbCommand dbCommand = dbconn.CreateCommand();
dbCommand.CommandText = orderSQL;
dbCommand.CommandType = CommandType.Text;
DbDataAdapter dbDataAdapter = dbfactory.CreateDataAdapter();
dbDataAdapter.SelectCommand = dbCommand;
if (System.Data.ConnectionState.Open != dbconn.State)
dbconn.Open();
DataSet dataSet = new DataSet();
int count = dbDataAdapter.Fill(dataSet, currentIndex, pageSize, "a_wsinterfaceinfo");
if (System.Data.ConnectionState.Open == dbconn.State)
dbconn.Close();
DataTable table =new DataTable();
dataSet.Merge(table);