数据库操作类
问题一:
public DataSet SelectDataBase(string tempStrSQL, string tempTableName)
{
this.strSQL = tempStrSQL;
this.myConnection = new SqlConnection(connectionString);
this.da = new SqlDataAdapter(this.strSQL, this.myConnection);
this.ds.Clear();
this.da.Fill(ds, tempTableName);
return ds;//返回填充了数据的DataSet,其中数据表以tempTableName给出的字符串命名
}
网上找的数据库操作类里面 有这么一段代码 有点看不懂
那个tempTableName 在调用的时候 具体要怎么定义 或者说这段代码具体怎么用
问题二:如下代码
public int UpdateDataBase(string tempStrSQL)
{
this.myConnection = new SqlConnection(connectionString);
//使用Command之前一定要先打开连接,后关闭连接,而DataAdapter则会自动打开关闭连接
myConnection.Open();
SqlCommand tempSqlCommand = new SqlCommand(tempStrSQL, this.myConnection);
int intNumber = tempSqlCommand.ExecuteNonQuery();//返回数据库中影响的行数
myConnection.Close();
return intNumber;
}
返回了一个int 如果我是想判断一下 是否有返回一个int 然后再根据结果 进行不同的操作
就是有返回数据的时候 一个操作 没返回数据的时候一个操作 哪要怎么写呢
请大侠们踊跃指教呀