一个ASP与sql 的问题!

来源:百度知道 编辑:UC知道 时间:2024/05/28 15:44:19
Sql = "Select * From M_Affiche Where A_Del = 0 and A_ID = "&A_ID
Set Myrs = Conn.execute(Sql)
if Not myrs.eof Then
A_ID = myrs("A_ID")
A_Title = myrs("A_Title")
A_Content = myrs("A_Content")
A_Time = myrs("A_Time")
else
Response.Redirect("Index.asp")
end if
Set Myrs = Nothing

请解释一下,上述代码的大体含义!

给变量赋值,为一个SQL语句,打开m_affiche表 如果 d_del=0 且 a_id=指定值
Sql = "Select * From M_Affiche Where A_Del = 0 and A_ID = "&A_ID
打开数据表,myrs为表对象
Set Myrs = Conn.execute(Sql)
if Not myrs.eof Then
如果有记录就取出各字段的内容
A_ID = myrs("A_ID")
A_Title = myrs("A_Title")
A_Content = myrs("A_Content")
A_Time = myrs("A_Time")
else
如果没有记录就转到 index.asp 页面
Response.Redirect("Index.asp")
end if
清空变量(好习惯)
Set Myrs = Nothing