public DataSet GetSingleQueryList(string condition)
{
SqlParameter[] parameters={ new SqlParameter("@condition1",SqlDbType.NVarChar,50),
new SqlParameter("@condition2",SqlDbType.NVarChar,50)};
parameters[0].Value=condition1;
parameters[1].Value=condition2;
return RunProcedure("sp_Single_Query",parameters,"EnterpriseRegister");
}
private SqlCommand BuildQueryCommand(string storedProcName, IDataParameter[] parameters)
{
SqlCommand command = new SqlCommand( storedProcName, conn );
command.CommandType = CommandType.StoredProcedure;
foreach (SqlParameter parameter in parameters)
{
command.Parameters.Add( parameter );
}
return command;
}
public DataSet RunProcedure(string storedProcName, IDataParameter[] parameters, string tableName )
{
conn = new SqlConnection(EnterpriseConn);
DataSet dataSet = new DataSet();
conn.Open();
SqlDataAdapter sqlDA = new SqlDataAdapter();
sqlDA.SelectCommand = BuildQueryCommand( storedProcName, parameters );
sqlDA.Fill( dataSet, tableName );
conn.Close();
return dataSet;
}
http://www.microsoft.com/china/community/Column/78.mspx