Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

data from database not appears...

Posted on 2003-12-01
4
Medium Priority
?
323 Views
Last Modified: 2006-11-17
i'm try running this code..

<html><head><title>Carian Harta </title></head>
<BODY><body background="blegtext.gif">

<p align="center" background="blue"><b><font size="5" font color=blue>SENARAI CARIAN</font></b><p>

<hr>


<%

pilihan      =Request.Form("pilihan")
nilai      =Request.Form("nilai")

'########## DSN-less connections ############################################################################################
Dim DBName, objConn, rs, strSQL      '//Variables we need
DBName = server.mappath("spick98.mdb")'//Database file !CHANGE IF NEEDED!

'//Create ADO connection
Set objConn = Server.CreateObject("ADODB.Connection")

'//Open our student database with this string
objConn.ConnectionString = "DBQ=" & DBName & ";Driver={Microsoft Access Driver (*.mdb)};"

'//Access our database
objConn.Open DAFTARHARTASH01

'//Create a recordset
Set rs = Server.CreateObject("ADODB.Recordset")
'######################################################################################################


If pilihan="No Harta1" Then
       strSQL="SELECT* FROM DAFTARHARTASH01 WHERE no_harta1=' " & nilai & " ' "
       set rs=objConn.execute(strSQL)
      bil=0

      response.Write("<hr><table border=" & 2)
      response.Write("<tr><td>Bil.</td><td>No Harta1</td><td>Jenama</td><td>No Siri</td></tr>")


Do While NOT rs.EOF
      bil=bil + 1
      response.Write("<tr><td><b>" & bil & "</b></td>")
      response.Write("<td><b>" & rs("no_harta1") & "</b></td>")
      response.Write("<td><b>" & rs("jenama")  & "</b></td>")      
      response.Write("<td><b>" & rs("no_siri") & "</b></td></tr>")
      
 rs.MoveNext
 Loop
      response.Write("</table border>")

If bil = 0 THEN
      response.Write("<hr><h2>Tiada Rekod</h2>")
       End If

Else
strSQL="SELECT no_harta1,jenama,no_siri FROM DAFTARHARTASH01 WHERE no_siri =' " & nilai & " ' "
       set rs1=objConn.execute(strSQL)
      bilangan=0
      response.Write("<hr><table border=" & 2 )
      response.Write("<tr><td>Bil.</td><td>No Harta1</td><td>Jenama</td><td>No siri</td></tr>")

 Do While NOT rs1.EOF
      bilangan=bilangan + 1
      response.Write("<tr><td><b>" & bilangan & "</b></td>")
      response.Write("<td><b>" & rs1("no_harta1") & "</b></td>")
      response.Write("<td><b>" & rs1("jenama")  & "</b></td>")      
      response.Write("<td><b>" & rs1("no_siri") & "</b></td></tr>")
      
rs1.MoveNext
Loop
      response.Write("</table border>")
 If bilangan = 0 THEN
      response.Write("<hr><h2>Tiada Rekod</h2>")
       End If
 End If


%>
</body></html>


there are no errors, the output display but data i'm searching from data base not appears...why????

0
Comment
Question by:eez81
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 39

Expert Comment

by:appari
ID: 9855885
i think no data is returned, check the sql and run it in mdb and see whether the sql is returning any data or not.

and in the sql you are building
>>strSQL="SELECT no_harta1,jenama,no_siri FROM DAFTARHARTASH01 WHERE no_siri =' " & nilai & " ' "
there is an extra space around in the where clause.

change above line with

strSQL="SELECT no_harta1,jenama,no_siri FROM DAFTARHARTASH01 WHERE no_siri ='" & nilai & "' "


 
 
0
 

Author Comment

by:eez81
ID: 9856184
TO appari
it's work better now...

if u see the code below,an output show all the data which have a alphabetic 'z'. my problem is,i just want to display data which first word start with 'z'.
<%
'########## DSN-less connections ############################################################################################
Dim DBName, objConn, rs, strSQL      '//Variables we need
DBName = server.mappath("spick98.mdb")'//Database file !CHANGE IF NEEDED!

'//Create ADO connection
Set objConn = Server.CreateObject("ADODB.Connection")

'//Open our student database with this string
objConn.ConnectionString = "DBQ=" & DBName & ";Driver={Microsoft Access Driver (*.mdb)};"

'//Access our database
objConn.Open

'//Create a recordset
Set rs = Server.CreateObject("ADODB.Recordset")
'######################################################################################################

      strSQL = "SELECT * FROM DAFTARHARTASH01 WHERE jenama LIKE'%z%';"
      Set rs= objConn.execute(strSQL)
      bil=0
      response.Write("<br><table border=" & 2 )
      response.Write("<tr><td>Bil.</td><td>Matrik</td><td>Nama</td><td>Mel</td></tr>")

Do While NOT rs.EOF
      bil=bil + 1
      response.Write("<tr><td><b>" & bil & "</b></td>")
      response.Write("<td><b>" & rs("id_no") & "</b></td>")
      response.Write("<td><b>" & rs("jenama")  & "</b></td>")
      response.Write("<td><b>" & rs("no_harta1")  & "</b></td>")
      response.Write("<td><b>" & rs("kod_kumpulan")  & "</b></td>")
      response.Write("<td><b>" & rs("no_siri")  & "</b></td>")      
      response.Write("<td><b>" & rs("lokasi") & "</b></td></tr>")
      
 rs.MoveNext
 Loop
      response.Write("</table border>")
 rs.close
%>
0
 
LVL 39

Accepted Solution

by:
appari earned 100 total points
ID: 9856336
change
strSQL = "SELECT * FROM DAFTARHARTASH01 WHERE jenama LIKE'%z%';"

to

strSQL = "SELECT * FROM DAFTARHARTASH01 WHERE jenama LIKE 'z%';"
0
 

Author Comment

by:eez81
ID: 9856492
thank you so much..
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question