 |
|
รบกวนพี่ๆ และผู้รู้ทุกท่านด้วยนะค่ะ เกี่ยวกับ Error ของ Code ค่ะ |
|
 |
|
|
 |
 |
|
<%@ language = vbscript%>
<!-- #include file="../helpdesk_system/conn.asp" -->
<%
sql1 = "Select * from Helpdesk_Job_type"
set rsjobtype = Conn_helpdesk.execute(sql1)
sql2 = "select * from Helpdesk_Service_order"
set rs_s = Conn_helpdesk.execute(sql2)
set rs_s = Server.CreateObject("adodb.recordset")
'rs_s.Open sql2,Conn_helpdesk,1,3
'*******************************************************
a_date = now()
'**************************************************
SQL="SELECT * FROM Helpdesk_Service_order WHERE a_date = #"& year(date)&"/"&month(date)&"/"&day(date)&"#"
'**************************************************
set RS = Conn_helpdesk.execute(SQL)
set RS = Server.CreateObject("adodb.recordset")
RS.Open SQL,Conn_helpdesk,1,3
'**************************************************
If Request.Form("Job_Id")<>"" Then
'=========ส่วนการสร้าง ID ในขอบเขตวันที่
IDdate=Right(year(date),2) '== สร้าง ID 1-2 ด้วยหลักหน่วยและหลักสิบของ ค.ศ.
If len(Month(date))=1 then '== สร้าง ID 3-4 ด้วย ค่าเดือนและเช็คหลักด้วย ถ้ามีหลักเดียวก็ เติม 0
IDdate=IDdate & "0" & Month(date)
Else
IDdate=IDdate & Month(date)
End If
If len(day(date))=1 then '== สร้าง ID 5-6 ด้วย ค่าวันและเช็คหลักด้วย ถ้ามีหลักเดียวก็ เติม 0
IDdate=IDdate & "0" & day(date)
Else
IDdate=IDdate & day(date)
End If
'=========ส่วนการสร้าง ID ในขอบข่าย จำนวน
RS.AddNew
RS("Service_id")=IDdate & Request.Form("Job_Id") & "001"
RS("a_date")=year(date)&"/"&month(date)&"/"&day(date)
RS.Update
Else
'=========ส่วนการสร้าง ID ในขอบเขตวันที่
IDdate=Right(year(date),2) '== สร้าง ID 1-2 ด้วยหลักหน่วยและหลักสิบของ ค.ศ.
If len(Month(date))=1 then '== สร้าง ID 3-4 ด้วย ค่าเดือนและเช็คหลักด้วย ถ้ามีหลักเดียวก็ เติม 0
IDdate=IDdate & "0" & Month(date)
Else
IDdate=IDdate & Month(date)
End If
If len(day(date))=1 then '== สร้าง ID 5-6 ด้วย ค่าวันและเช็คหลักด้วย ถ้ามีหลักเดียวก็ เติม 0
IDdate=IDdate & "0" & day(date)
Else
IDdate=IDdate & day(date)
End If
'=== ตรวจสอบค่าขอบข่ายจำนวน
topstaffID=0
RS.MoveFirst
Do Until RS.EOF
If Request.Form("Job_Id")=Mid(RS("Service_id"), 7, 1) Then
if cInt(Right(RS("Service_id"),3))>topstaffID Then topstaffID=cInt(Right(RS("Service_id"),3))
End If
RS.MoveNext
Loop
'=========ส่วนการสร้าง ID ในขอบข่าย จำนวน
IDstaff=cInt(Right(RS("Service_id"),3))+1 '=== นำค่า 3 ตัวของ ID มา แปลงเป็นเลขจำนวนเต็ม
IDstaff=topstaffID+1
If len(IDstaff)=1 Then
IDstaff="00" & IDstaff
ElseIf len(IDstaff)=2 Then
IDstaff="0" & IDstaff
End If
RS.AddNew
RS("Service_id")=IDdate & Request.Form("Job_Id") & IDstaff
RS("a_date")=year(date)&"/"&month(date)&"/"&day(date)
RS.Update
End If
RS.Close
Set RS=Nothing
End If
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<title>Select Job Type</title>
<body>
<!-- <link href="style/style.css" rel="stylesheet" type="text/css"> -->
<FORM name = "userinfo" action="Select_Job_Type.asp" method="post" onsubmit="">
<p>
<label>ลักษณะงานที่ซ่อม</label><!--comment>ลักษณะงานที่ซ่อม<!--comment-->
<select name="Job_Id" >
<option value="" selected >--โปรดเลือก ลักษณะงาน--</option>
<%
strsql1 = "Select * from Helpdesk_Job_type "
Set rsjobtype = Conn_helpdesk.execute(strsql1)
do until rsjobtype.eof
response.write"<option value ="""&rsjobtype("Job_Id")&""">"&rsjobtype("Type_Detail")&"</option>"
rsjobtype.movenext
loop
%>
</select>
</p>
<p>
<input type=reset name=reset value="Reset" >
<input type="submit" name= Submit value="Save" >
</form>
</p>
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '#'.
/helpdesk_system/select_job_type.ASP, line 17
แล้วถ้าเปลี่ยนจากเครื่องหมาย # เป็น % จะแสดง Error
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '2006'.
/helpdesk_system/select_job_type.ASP, line 17
หรือถ้าไม่ใส่เครื่องหมายอะไรเลยก้อจะ error
Error Type:
ADODB.Recordset (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/helpdesk_system/select_job_type.ASP, line 56
error ตรงนี้อ่ะค่ะ[RS.MoveFirst]
ใช้ฐานข้อมูล MSSQL ค่ะ a_date เป็นแบบ datetime ค่ะ
รบกวนพี่ๆ และผู้รู้ทุกท่านด้วยนะค่ะ
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
26 ม.ค. 2549 08:39:35 |
By :
May |
View :
2726 |
Reply :
7 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองแสดงค่าของตัวแปร sql มาดูก่อนนะครับว่าค่าที่ได้เป็นอย่างไร
SQL="SELECT * FROM Helpdesk_Service_order WHERE a_date = #"& year(date)&"/"&month(date)&"/"&day(date)&"#"
response.write sql 'ค่าที่ได้น่าจะเป็น SELECT * FROM Helpdesk_Service_order WHERE a_date = #2006/1/27#
ดังนั้นแล้วไปตรวจสอบดูในฐานข้อมูลในฟิลด์ที่ชื่อ a_date ว่าเก็บวันที่ในรูปแบบนี้หรือเปล่า 2006/1/27 ผมก็ไม่รู้หรอกนะว่าในฐานข้อมูลของ MS SQL ฟิลด์ที่เป็น Date/Time โดยดีฟอลท์แล้วจะเก็บในรูปแบบใด แต่คาดน่าว่าจะเป็น 27/1/2006 นะครับ และจาก Error ที่แจ้งมาคาดว่าน่าจะไม่ต้องใส่เครื่องหมาย # หรือ % คร่อมวันที่นะครับ
ยังไงก็ลองดูนะครับ เห็นว่าความพยายามมีสูงก็เลยติดตาม
|
 |
 |
 |
 |
Date :
27 ม.ค. 2549 08:52:16 |
By :
นายกระจอก |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผลที่ได้เป็นลักษณธแบบนี้ค่ะ SELECT * FROM Helpdesk_Service_order WHERE a_date = 2006/1/26
แต่ไปเปิดดูในฐานข้อมูลจะเป็น 26/1/2006 ค่ะ
|
 |
 |
 |
 |
Date :
27 ม.ค. 2549 09:09:14 |
By :
May |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เห้อน้องก็เปลี่ยนคำสั่ง sql หน่อยสิครับ
เป็น SQL="SELECT * FROM Helpdesk_Service_order WHERE a_date = "& day(date)&"/"&month(date)&"/"&year(date)
ก็แค่นั้นแหละจ๊ะ
|
 |
 |
 |
 |
Date :
27 ม.ค. 2549 11:38:31 |
By :
นายกระจอก |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณพี่นายกระจอกค่ะ
พี่ค่ะ ตรงบรรทัดนี้
IDstaff=cInt(Right(RS("Service_id"),3))+1 '=== นำค่า 3 ตัวของ ID มา แปลงเป็นเลขจำนวนเต็ม
เจอ Error Type: (0x80020009) Exception occurred.
|
 |
 |
 |
 |
Date :
27 ม.ค. 2549 12:41:23 |
By :
May |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โดยปกติแล้วนะครับใน VBScript ตัวแปรจะเป็นแบบ Variant (พิมพ์ถูกไหมหนอ) คือประมาณว่า ไม่ต้องกำหนดให้ว่าตัวแปรจะต้องเป็นตัวแปรชนิด integer หรือ text หรือ double ประมาณนี้ เพราะว่ามันจะกำหนดชนิดของตัวแปรให้เองโดยอัตโนมัติ จากบรรทัดดังกล่าวน่าจะเป็นแบบนี้นะ
IDstaff=Right(RS("Service_id"),3))+1
หรือถ้าอยากให้กระจ่างก็เอา Error Code คือ 0x80020009 ไปค้นหาในกูเกิ้ลหรือเสริชเอ็นจิ้นอื่น ๆ ก็จะทำให้เราทราบสาเหตุเกี่ยวกับ Error นั้น ๆ (ต้องรู้ภาษาอังกฤษนิดหน่อยนะ)
|
 |
 |
 |
 |
Date :
27 ม.ค. 2549 13:47:42 |
By :
นายกระจอก |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณค่ะ
|
 |
 |
 |
 |
Date :
27 ม.ค. 2549 14:28:58 |
By :
May |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|