一些ASP的简单应用

时间转换为字符形式:

convert(varchar(10) , yourdatetime , 120)

ASP  SELECT CASE应用..

select    case  类

case  1

response.wirte 1

case 2

response.write 2

end select

 插入,删除,修改:

<%  'insert / update /delete
objComm.CommandText = "INSERT INTO userstu(StuName) VALUES('张名副')"  '接受sql语句
objComm.Execute intNoOfRecords  '执行
Response.Write "插入的行数:" & intNoOfRecords
%>

<%  'insert / update /delete
objComm.CommandText = "update userstu set stuname='张因挖' where stuname like '%张名副%'"  '接受sql语句
objComm.Execute intNoOfRecords  '执行
Response.Write "<br/>修改的行数:" & intNoOfRecords
%>

<%  'insert / update /delete
objComm.CommandText = "delete from userstu where stuname like'%张因挖%'"  '接受sql语句
objComm.Execute intNoOfRecords  '执行
Response.Write "<br/>删除的行数:" & intNoOfRecords
%>

一种SQL\连接代码:

<%
Option Explicit
dim conn,connstr,objComm,objRS,intNoOfRecords,sql
'连接SQL Server 数据库
connstr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=LMS;Data Source=xiaoqiang"
set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = connstr  '连接字符串
objComm.CommandType = 1 '连接类型


%>

你可能感兴趣的:(sql,SQL Server,Security,asp)