Solved

data from database not appears...

Posted on 2003-12-01
4
320 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 25 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
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…

749 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