我正在尝试学习asp.net,并且很早就遇到了问题。
我正在尝试连接到我在Net Registry的Cloud Hosting上创建的数据库。
我尝试访问该页面时收到500错误。
(如果这很重要,我也在Mac上。)
这是我的代码:
<% @ Language="VBScript" %>
<head>
<title>Form to database</title>
</head>
<body>
<%
Dim page: page = Request.ServerVariables("SCRIPT_NAME")
If Request.Form <> "" Then
Dim name: name= Request.Form("name")
Dim email: email = Request.Form("email")
Dim comments: comments = Request.Form("comments")
Dim sql: sql = "INSERT INTO users_tbl " & _
"([name], email, comments) " & _
"VALUES ('" & name & "','" & email & "','" & comments & "')"
Dim conn: Set conn = Server.CreateObject("ADODB.Connection")
Dim str: str = "SERVER=MYSQL-5.idealinsurance.com.au;
DATABASE=ideal_idealinsurance_com_au; UID=XXXXXXXXXX;PASSWORD=XXXXXXXX; OPTION=3"
conn.Open(str)
conn.Execute(sql)
conn.Close
Set conn = Nothing
Dim message: message = "The form information was inserted successfully."
End If
%>
<form action="<%=page%>" method="post">
name:<input name="name"><br>
email:<input name="email"><br>
comments: <textarea name="comments"></textarea><br>
<input name="submit" type="submit" value="Submit">
</form>
<p>
<%=message%>
</body>
</html>