|
![](/images/resource/spacer.gif) |
|
ต้องการผู้รู้ด่วน(updtate program มวไหม่แล้ว) code คือ ' Criteria = WHERE [LIKE] |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
code คือ
<%
' Criteria = " WHERE [LIKE] <> '0' "
'if Request("Submit") = "Search" then
' if request.form("[LIKE]") <> "" then
' Criteria = Criteria & " AND [LIKE] = '" & request.form("[LIKE]") & "'"
' end if
' if request.form("date") <> "" then
' Criteria = Criteria & " AND date = '" & request.form("date") & "'"
'end if
' if request.form("id_customer") <> "" then
' Criteria = Criteria & " AND id_customer = " & request.form("id_customer")
'end if
'
'end if
worklike = request.Form("[LIKE]")
%>
<HTML>
<HEAD>
<TITLE> Database Management System</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=windows-874">
</HEAD>
<BODY>
<form name="send" action="select.asp" method="post" >
<table width="52%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><div align="center">ค้นหา </div></td>
</tr>
<tr>
<td width="34%"><span lang="th">ความถนัด</span>:</td>
<td width="66%"><label>
<input name="[LIKE]" type="text" id="[LIKE]">
</label></td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" name="Submit" value="Search">
<input type="submit" name="Submit2" value="Reset">
</label></td>
</tr>
</table>
</form>
<BR></TD>
<br>
<%
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("test_project_update.mdb")
'Sql="Select EMPLOYEE.E_MAIL,EMPLOYEE.TEL,
extra.ID_extra,extra.EMP_ID,extra.NAME_THAI,extra.SURENAME_THAI,extra.LIKE
from EMPLOYEE,extra" & Criteria
'Sql="Select EMPLOYEE.E_MAIL,EMPLOYEE.TEL,
extra.ID_extra,extra.EMP_ID,extra.NAME_THAI,extra.SURENAME_THAI,extra.LIKE
from EMPLOYEE,extra
where [like] like '%" & worklike & "%'"
Set RS =Server.CreateObject("ADODB.Recordset")
RS.open Sql,Conn,1,3
if RS.recordcount <> 0 then
RS.MoveFirst
end if
%>
<TABLE border="1">
<TR>
<TD> <span lang="th">รหัสความถนัด</span> </TD>
<TD> <span lang="th">รหัสพนักงาน</span> </TD>
<TD> <span lang="th">ชื่อ</span> </TD>
<TD> <span lang="th">นามสกุล</span> </TD>
<TD> <span lang="th"> E_MAIL</span> </TD>
<TD> <span lang="th">TEL</span> </TD>
<TD> <span lang="th">ความถนัด</span> </TD>
</TR>
<%
if RS.recordcount <> 0 then
Do While Not RS.EOF
%>
<TR>
<TD><%= RS("ID_extra")%></TD>
<TD><%= RS("EMP_ID")%></TD>
<TD><%= RS("NAME_THAI")%></TD>
<TD><%= RS("SURENAME_THAI")%></TD>
<TD><%= RS("E_MAIL")%></TD>
<TD><%= RS("TEL")%></TD>
<TD><%= RS("LIKE")%></TD>
</TR>
<%
RS.MoveNext
Loop
end if
%>
</TABLE>
<html>
<body>
</body>
</html>
<p> </p>
<%
rs.close
conn.close
%>
</BODY>
</HTML>
---------------------------------------------------------------------------
Error Type
Microsoft VBScript compilation (0x800A0409)
Unterminated string constant
/project/select.asp, line 54, column 31
from EMPLOYEE,extra" & Criteria
------------------------------^
Tag : - - - -
![](/images/adv.jpg?v=1001)
|
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
20 พ.ย. 2550 00:50:37 |
By :
p |
View :
1600 |
Reply :
2 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ลองเอา SQL มาดูแบบเต็มๆ น่ะ Response.write Sql
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
20 พ.ย. 2550 08:42:55 |
By :
อิอิ |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
'Sql="Select EMPLOYEE.E_MAIL,EMPLOYEE.TEL,
extra.ID_extra,extra.EMP_ID,extra.NAME_THAI,extra.SURENAME_THAI,extra.LIKE
from EMPLOYEE,extra
where [like] like '%" & worklike & "%'"
อันนี้ไปเอาข้อมุลมาจากสองตาราง แต่ทั้งสองตารางนี้ ไม่มีมีส่วนเกี่ยวข้องกันเลย ถึงมันมาก็จะเยอะมาก (ไม่มี join)
'Sql="Select EMPLOYEE.E_MAIL,EMPLOYEE.TEL,
extra.ID_extra,extra.EMP_ID,extra.NAME_THAI,extra.SURENAME_THAI,extra.LIKE
from EMPLOYEE,extra" & Criteria
อันนี้เงี่อนไขเด็ด อยู่ที่ Criteria แต่ถ้าย้อนกลับขึ้นไปข้างบน Criteria ถูกคอมเม้นต์ไว้หมด
แต่ sql ทั้งสองอันที่ผมยกมา นั้น
- ดูแล้วคุณคอมเม้นต์มันไว้ทั้งสองเลย ตกลงคุณใช้อันไหนกันแน่
- ไม่มีการ join ทั้งสองชุดเลย
- ผมไม่รู้ว่าใครเป็นคนตัดบรรทัด เว็บบอร์ดนี้มันตัดบรรทัดให้คุณ หรือว่าคุณตัดมาเอง หรือว่า ในโค้ดของคุณก็ตัดอย่างนี้ ถ้าเป็นประเด็นสุดท้าย คือ ในไฟล์ของคุณนะครับ ตัดบรรทัดตามนี้ ก็ผิดครับ ผิดแน่ เพราะโค้ดมันอ่านคำสั่งเป็นบรรทัด แนะนำว่าถ้ามันยาวเกินไปก็ใช้ตัว เชื่อมบรรทัดครับ เพื่อให้โค้ดมันมองว่าเป็นบรรทัดเดียวกัน
Sql="SELECT employee.email, employee.tel, extra.id_extra, extra.emp_id, " _
& "extra.name_thai, extra.surname_thai, extra.like " _
& "FROM employee INNER JOIN extra ON employee.id = extra.emp_id " _
& "WHERE (extra.like LIKE '%" & worklike & "%');"
ผมลองเดา แล้วเขียนขึ้นมาใหม่ ประมาณนี้นะครับ ลองเอาไปวางแทนดูครับ อ้อ เพราะมันเดาอ่ะครับ บรรทัดการ join น่ะ ไม่แน่ใจว่าชื่อฟิลด์ที่ต้อง join น่ะใช่หรือเปล่านะ ดูตรงนั้นด้วยละกัน
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
20 พ.ย. 2550 10:29:00 |
By :
GTM |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 00
|