多做题,通过考试没问题!

计算机科学与技术(本科)

睦霖题库>国家开放大学(电大)>计算机科学与技术(本科)

已知数据表Student存储在SQL Server服务器的School数据库中,用户名为sa,密码为xyz123,创建student数据表的命令为:  CREATE TABLE Student (  SName varchar(20)  Primary Key Not NULL,  SPwd Varchar(15) Not NULL  )  试根据下面的代码使用命令对象完成在student数据表中插入一条记录。  <%  tname = Request.Form("txtName")  ’接收到的用户名  tpwd = Request.Form("txtPwd")   ’接收到的密码  %>

正确答案: <%
Set conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=(local);UID=sa;PWD=xyz123;database=School"
Set comm = Server.CreateObject("ADODB.Command")
Comm.ActiveConnection=conn
Comm.CommandText = "Insert into student values(’"&tname&"’,’"&tpwd&"’)"
Comm.Execute
Conn.Close
Set conn = Nothing
%>
答案解析:
进入题库查看解析

微信扫一扫手机做题