您的位置:首页 > 数据库

C#/Access-数据库获取自动编号的最大值

2014-03-26 17:37 323 查看
//conStrSQL你改成你的access,我这里用的SQL2005
string conStrSQL = "Data Source=xx.xx.xx.xx;Initial Catalog=xxxxx;User ID=xx;Password=xxxx";
string strSQL = "select max(自动编号字段)from table";
conn = new SqlConnection(conStrSQL);
SqlCommand cmd = new SqlCommand(strSQL, conn);
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
DataSet ds = new DataSet();
sda.Fill(ds);
MessageBox.Show(ds.Tables[0].Rows[0][0].ToString());
http://bbs.csdn.net/topics/390400517?page=1#post-393993079
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: