连接错误vbscript sqlserver?

时间:2011-03-09 18:18:12

标签: sql-server vbscript connection-string oledb adodb

<%@ language="vbscript" %>
<html>
<body>
<P>
<%

dim adOpenDynamic,adLockOptimistic,adCmdtext

adOpenDynamic=0

adLockoptimistic=1

adCmdtext=2
dim i
i=1
dim conn,rs,strsql
dim fname,lname,gender,month,date,year,uname,pwd,email


set conn=Server.Createobject("ADODB.Connection")
set rs=Server.Createobject("ADODB.Recordset")

conn.ConnectionString="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=myshoppe;Data Source=NVC-10\SQLEXPRESS"

conn.Open

fname=Request.Form("first_name")
lname=Request.Form("last_name")
gender=Request.Form("gender")
'month=Request.Form("Month")
'date=Request.Form("date")
'year=Request.Form("year")
email=Request.Form("email")
uname=Request.Form("user_name")
pwd=Request.Form("pwd")

strsql = "INSERT INTO user_info(fname, lname, gender, email, uname, pwd) VALUES(' " & fname & "',' " & lname &"',' " & gender & "',  "& email & "',' " & uname & "',' " & pwd & "')"                                                                

conn.Execute (strsql)
Response.Write("submitted<>")

Response.Write "Connected OK"


%>
<br>


</P>

</body>
</html>
  

Microsoft OLE DB Provider for SQL   服务器(0x80040E09)INSERT权限   对象'us​​er_info',数据库被拒绝   'myshoppe',schema'dbo'。

1 个答案:

答案 0 :(得分:1)

您需要在电子邮件变量之前打开单引号。