您的位置:首页 > 移动开发

Microsoft.ApplicationBlocks使用心得

2004-10-19 12:18 323 查看
查询返回单行ID

string sql = string.Format("select id from account where name='{0}' and password='{1}'", name, password);
object AID = SqlHelper.ExecuteScalar(CON_STR, CommandType.Text, sql);
int ID = Convert.ToInt32(AID);

插入返回新记录ID


string sql = string.Format("insert into account (name ,password) values ('{0}', '{1}'); Select CAST(@@Identity AS INTEGER)", account.Name, account.Password);
object AID = SqlHelper.ExecuteScalar(CON_STR, CommandType.Text, sql );
int id = Convert.ToInt32(AID);

查询返回多行记录


string sql = string.Format("select id, name, password from account where id={0}", id);
SqlDataReader dr = SqlHelper.ExecuteReader(CON_STR, CommandType.Text, sql);
if (dr.Read())
dr.Close();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: