sql插入更新删除语句

   日期:2017-06-15

<%
'插入sql语句(一个字段)
sql="INSERT INTO BigClass (BigClassName) VALUES ('" & NewClassName & "')"
conn.Execute (sql)
'-----------------------------------------------------------------------------------------------
'插入sql语句(二个字段,注意数字和字符字段的区别)
conn.execute("insert into SmallClass (BigClassID,SmallClassName) values (" & BigClassID & ",'" & SmallClassName & "')")
'------------------------------------------------------------------------------------------------
'插入sql语句(多个字段)
sql="INSERT INTO News (Title,Author,Original,Content,BigClassID,SmallClassID,UpdateTime) VALUES "
sql=sql & "(" & "'"& title & "'" & ","
sql=sql & "'"& Author &"'"&","
sql=sql & "'"& Original &"'"&","
sql=sql & "'"& Content &"'"&","
sql=sql & BigClassID &","
sql=sql & SmallClassID &","
sql=sql & "'" & Now() &"')"
conn.Execute (sql)
'-----------------------------------------------------------------------------------------------
conn.Execute("INSERT INTO admin (user,pwd) VALUES ('"&addusername&"','"&addpassword&"')")
'-----------------------------------------------------------------------------------------------
sql="insert into message (incept,sender,title,content) values ('"&incept&"','"&membername&"','"&title&"','"&message&"')"
conn.execute(sql)
'/////////////////////////////////////////////////////////////////////////////////////////////////
'更新
sql="update Admin set AdminPWD='" & NewPassword & "' where AdminUID='" & UserName & "'" 
conn.execute(sql)
'---------------------------------------------------------------------------------------------
sql="update BigClass set BigClassName='" & NewClassName & "' where BigClassID=" & OldClassID
conn.execute(sql)
'-------------------------------------------------------------------------------------
'/////////////////////////////////////////////////////////////////////////////////////////////////
'删除
conn.execute("delete from BigClass where BigClassID=" & BigClassID)
conn.execute("delete from News where NewsID=" & NewsID)
conn.execute("delete from BigClass")
%>