ส่วนของตาราง ค่ะ
Table Budgets
Field name --------------> Data Type
Budgets_ID --------------> AutoNumber
BudgetsName------------> Text
Project --------------------> Text
DateInput -----------------> Date/Time
Site_ID --------------------> Text
UserName ----------------> Text
Department_ID ----------> Number
Type_ID -------------------> Number
CodeBudgets_ID --------> Number
ส่วนของ Code ค่ะ
<% Option Explicit %>
<%
Dim Conn,strSQL,objRec,objExec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath("../DBACC/DB_SUTT_V2.accdb") & ";Jet OLEDB:Database Password=sutt242;"
strSQL = "SELECT * FROM Budgets WHERE Department_ID = '"&Request.Form("Department_ID")&"' AND Site_ID = '"&Request.Form("Site_ID")&"' AND CodeBudgets_ID = '"&Request.Form("ddlProvince")&"' AND Project = '"&Request.Form("Project")&"' "
Set objRec = Conn.Execute(strSQL)
IF Not objRec.EOF Then
Response.write("Budgets code for department of your already exist.")
Else
strSQL = ""
strSQL = strSQL &"INSERT INTO Budgets "
strSQL = strSQL &"(BudgetsName,Project,DateInput,Site_ID,UserName,Department_ID,User_ID,Type_ID,CodeBudgets_ID) "
strSQL = strSQL &"VALUES "
strSQL = strSQL &"('"&Request.Form("ddlAmphur")&"','"&Request.Form("Project")&"', '"&Request.Form("DateInput")&"' "
strSQL = strSQL &",'"&Request.Form("Site_ID")&"','"&Request.Form("UserName")&"', '"&Request.Form("Department_ID")&"') "
strSQL = strSQL &",'"&Request.Form("User_ID")&"','"&Request.Form("ddlGeo")&"', '"&Request.Form("ddlProvince")&"') "
Set objExec = Conn.Execute(strSQL)
If Err.Number = 0 Then
Response.write("Save Done.")
Else
Response.write("Error Save ["&strSQL&"] ("&Err.Description&")")
End If
Set objExec = Nothing
End If
objRec.Close
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>
พอรันแล้ว มัน error ว่า
Error Type:
Microsoft Office Access Database Engine (0x80040E07)
Data type mismatch in criteria expression.
/sutt_budgets_v.2/Create_Budgets_Code_INSERT_Checkdata_Enable.asp,
line 290