想实现的是格式为“20070510_001”的ID号 ,可是老是读不数据,帮忙看看啊!!急!
想实现的是格式为“20070510_001”的ID号 ,可是老是读不数据,直接读出catch中的返回值。不知道哪里写错了,高手帮忙看看!谢谢!
private string LoadIdBaseData()
{
string MyConString = ConfigurationSettings.AppSettings[ "strConn "];
string strSql= "Select top 1 Err_Id From Zq_Id_Data ";
int intId=0;
string ID = " ";
DateTime dt = DateTime.Now;
string str2 = string.Format( "{0:yyyyMMdd} ", dt);
User user=new User();
try
{
SqlConnection SqlCon =new SqlConnection(MyConString);
SqlCommand adoCMD=new SqlCommand(strSql,SqlCon);
SqlCon.Open();
SqlDataReader adoRead=adoCMD.ExecuteReader(CommandBehavior.CloseConnection);
if(adoRead.Read())
{
ID = adoRead.GetString(0);
}
adoRead.Close();
string str1 = ID.Substring(0, 8);
Response.Write(str1);
// if (str1 == str2)
// {
intId = Convert.ToInt32(ID.Substring(10, 12)) + 1;
ID = str1 + "_ " + intId.ToString().PadLeft(3, '0 ');
strSql = "Update Zq_Id_Data Set Err_Id= ' " + ID + " ' ";
SqlCon = new SqlConnection(MyConString);
&