1

I am trying to learn asp.net, and have hit a problem early on.

I am attempting to connect to a database that I have create on Net Registry's Cloud Hosting.

I just receive a 500 error when i try to access the page.

(I am on a Mac as well if this matters at all.)

Here is my code:

<% @ 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>
4

0 回答 0