<% Option Explicit %>
<html>
<head>
<title>ThaiCreate.Com ASP & SQL Server Tutorial</title>
</head>
<body>
<%
Dim Conn,strSQL,objRec,objExec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=localhost;Database=mydatabase;UID=sa;PWD=;"
strSQL = "SELECT * FROM customer WHERE CustomerID = '"&Request.Form("txtCustomerID")&"' "
Set objRec = Conn.Execute(strSQL)
IF Not objRec.EOF Then
Response.write("CustomerID already exist.")
Else
strSQL = ""
strSQL = strSQL &"INSERT INTO customer "
strSQL = strSQL &"(CustomerID,Name,Email,CountryCode,Budget,Used) "
strSQL = strSQL &"VALUES "
strSQL = strSQL &"('"&Request.Form("txtCustomerID")&"','"&Request.Form("txtName")&"', '"&Request.Form("txtEmail")&"' "
strSQL = strSQL &",'"&Request.Form("txtCountryCode")&"','"&Request.Form("txtBudget")&"', '"&Request.Form("txtUsed")&"') "
Set objExec = Conn.Execute(strSQL)
If Err.Number = 0 Then
Response.write("Save Done.")
Else
Response.write("Error Save ["&strSQL&"]")
End If
Set objExec = Nothing
End If
objRec.Close
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>
</body>
</html>