<%
'declare the variables
Dim Recordset
Dim sql
dim Conn
Dim name1,email1,phone1,company1,title1
name1 = request.form("TxtName")
email1 = request.form("TxtEmail")
phone1 = request.form("TxtPhone")
company1 = request.form("TxtCompany")
title1 = request.form("TxtJob")
'create an instance of the ADO connection and recordset objects
Set Conn= Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
'open the connection to the database
Conn.ConnectionString = "DSN=blah;User Id=...;Password=...;Database=...."
'Open the recordset object executing the SQL statement and return records
Recordset.Open
Conn.open
sql="INSERT INTO register (Name, email, phonenumber, company, title)"
sql=sql & "values ('"& name1 &"','"& email1 &"','"& phone1 &"','"& company1 &"','"& title1 &"')"
Conn.Execute(sql)
Conn.Close()
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sample Registration Page</title>
</head>
<body>
<form name"form" action="">
<table>
<tr>
<td>Full Name:</td>
<td>
<input name="TxtName" id="TxtName" type="text" />
</td>
</tr>
<tr>
<td>Email:</td>
<td>
<input name="TxtEmail" id="TxtEmail" type="text" />
</td>
</tr>
<tr>
<td>Phone:</td>
<td>
<input name="TxtPhone" id="TxTPhone" type="text" />
</td>
</tr>
<tr>
<td>Company:</td>
<td>
<input name="TxtCompany" id="TxtCompany" type="text" />
</td>
</tr>
<tr>
<td>Job Title:</td>
<td>
<input name="TxtJob" id="TxtJob" type="text" />
</td>
</table>
<input name="button" ID="Button1" value="submit" type="Submit" />
</form>
</body>
</html>
我收到一條error 500
消息,當我運行這個頁面時,我不知道我的錯誤在哪裏。ASP連接到SQL Server數據庫
我也做了名爲blah的名爲DSN連接到我的SQL Server。
我跑了ASP的一部分,它的工作原理,但數據庫部分是我的問題所在。我非常感謝任何幫助,因爲我相對較新。
你確定它是asp.net嗎?看起來像經典的asp – 2014-09-26 23:29:25
Im對不起,這是正常的asp。我新來這個。對不起,我錯了。 – user2127632 2014-09-26 23:46:49
這不是「正常的」ASP,因爲它將在2014年成爲ASP.NET。這是傳統的ASP,它於2000年左右退役。 – TomTom 2014-09-27 07:21:10