日期:2014-05-17 浏览次数:20803 次
ALTER PROCEDURE USP_QueryT_AddressBookByField
@FieldName nvarchar(20),
@Val nvarchar(50)
AS
SET NOCOUNT ON
select [FId] as [编号],[FName] as [姓名],[FSex] as [性别],[FPhone] as [电话号码],[Fqq] as [QQ],
[FWordPhone] as [国际电话号码],[FEMail] as [EMail],[FHandSet] as [手机号] from [T_AddressBook] where
@FieldName = @Val
string query = @"Data Source=.\SQLExpress;Initial Catalog=PersonnelManagementSystem;Integrated Security=True";
_Set = new DataSet();
using(SqlConnection connect = new SqlConnection(query)) {
connect.Open();
using(SqlCommand cmd = connect.CreateCommand()) {
cmd.CommandText = "USP_QueryT_AddressBookByField";
cmd.Parameters.Clear();
cmd.Parameters.Add("@FieldName", SqlDbType.NVarChar, 20).Value = "FId";
cmd.Parameters.Add("@Val", SqlDbType.NVarChar, 50).Value = "00003";
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
_Set = new DataSet();
_DataAdapter = new SqlDataAdapter(cmd);
_DataAdapter.Fill(_Set, "T_AddressBook");
dgvDataTable.DataSource = _Set.Tables["T_AddressBook"];