数据访问类
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace Interview
{
class OperatorConnection
{
SqlConnection objSqlConnection = null;
SqlCommand objSqlCommand = null;
DataSet objDataSet = null;
SqlDataAdapter objSqlDataAdapter = null;
public OperatorConnection()
{
objSqlConnection = new SqlConnection("database=Wear;server=.;uid=sa;pwd=sa");
objSqlConnection.Open();
if (objSqlCommand == null)
{
objSqlCommand = new SqlCommand();
objSqlCommand.Connection = this.objSqlConnection;
}
}
public DataSet search(String sql, String strTableName)
{
try
{
objDataSet = new DataSet();
objSqlCommand.CommandType = CommandType.Text;
objSqlCommand.CommandText = sql;
objSqlDataAdapter = new SqlDataAdapter();
objSqlDataAdapter.SelectCommand = objSqlCommand;
objSqlDataAdapter.Fill(objDataSe