Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: help me


Message #1 by Jose Medeiros <jbnetto@c...> on Mon, 22 Jan 2001 16:03:28 -0200

Please somebody helps me. I am creating a page in ASP for use in my

homepage. I possess a called data base "farmaco.mdb". The fields of the

data

base are: "farmaco", "concentração" and "via". I created a page ASP in

the

Microsoft access and the pattern was the following one:



<html>

<head>

<title>Dosagem Medicamento</title>

</head>



<body bgcolor="#FFFFFF" text="#000080" link="#000080" leftmargin="15">



<%

Param = Request.QueryString("Param")

Data = Request.QueryString("Data")

%>

<%

Session.timeout = 10

If IsObject(Session("farmaco_conn")) Then

    Set conn = Session("farmaco_conn")

Else

    Set conn = Server.CreateObject("ADODB.Connection")

    cnpath="DBQ=" & server.mappath("\farmaco.mdb")

    conntemp.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & cnpath



    conn.open "farmaco","",""

    Set Session("farmaco_conn") = conn

End If

%>

<%

    sql = "SELECT * farmaco.mdb"

    If cstr(Param) <> "" And cstr(Data) <> "" Then

        sql = sql & " WHERE [" & cstr(Param) & "] = " & cstr(Data)

    End If

    Set rs = Server.CreateObject("ADODB.Recordset")

    rs.Open sql, conn, 3, 3

    %>

<TABLE BORDER=1 BGCOLOR=#ffffff CELLSPACING=0 align="center">

<THEAD>

<TR>

<TH BGCOLOR=#c0c0c0 BORDERCOLOR=#000000 ><FONT SIZE=1 FACE="Arial"

COLOR=#000000>Farmaco</FONT></TH>

<TH BGCOLOR=#c0c0c0 BORDERCOLOR=#000000 ><FONT SIZE=1 FACE="Arial"

COLOR=#000000>Concentração</FONT></TH>

<TH BGCOLOR=#c0c0c0 BORDERCOLOR=#000000 ><FONT SIZE=1 FACE="Arial"

COLOR=#000000>Via de aplicação</FONT></TH>



</TR>

</THEAD>

<TBODY>

<%

On Error Resume Next

rs.MoveFirst

do while Not rs.eof

 %>

<TR VALIGN=TOP>

<TD BORDERCOLOR=#c0c0c0 ><FONT SIZE=1 FACE="Arial"

COLOR=#000000><%=Server.HTMLEncode(rs.Fields("farmaco").Value)%><BR></FONT></TD>



<TD BORDERCOLOR=#c0c0c0 ><FONT SIZE=1 FACE="Arial"

COLOR=#000000><%=Server.HTMLEncode(rs.Fields("concentra").Value)%><BR></FONT></TD>



<TD BORDERCOLOR=#c0c0c0 ><FONT SIZE=1 FACE="Arial"

COLOR=#000000><%=Server.HTMLEncode(rs.Fields("via").Value)%><BR></FONT></TD>



</TR>

<%

rs.MoveNext

loop%>

</TBODY>

<TFOOT></TFOOT>

</TABLE></body>

</html>







My initial html page is this

I do not know to identify what this wrong one. I do not know if I have

that to substitute some thing. I am thankful who very I will be able to

help me.





Jose Medeiros





farmaco concentra via

farmaco_A concentra_1 IM

farmaco_B concentra_2 EV

farmaco_C concentra_3 BA

farmaco_D concentra_4 SD

farmaco_E concentra_5 SB

farmaco_F concentra_6 SC

farmaco_G concentra_7 PER

farmaco_H concentra_8 TRAS

farmaco_I concentra_9 RET





<HTML>



<TITLE>Farmaco</TITLE>



<TABLE BORDER=1 BGCOLOR=#ffffff CELLSPACING=0>





<form method="POST" action="farmaco.asp" name="farmaco"><select

name="farmaco" size="1" style="font-family: Arial; font-size: 8pt;

color: rgb(0,30,128)">

        <option>Farmaco</option>

<option value="farmaco_A">farmaco_A</option>

<option value="farmaco_B">farmaco_B</option>

<option value="farmaco_C">farmaco_C</option>

<option value="farmaco_D">farmaco_D</option>

<option value="farmaco_E">farmaco_E</option>

<option value="farmaco_F">farmaco_F</option>

<option value="farmaco_G">farmaco_G</option>

<option value="farmaco_H">farmaco_H</option>

<option value="farmaco_I">farmaco_I</option>

      </select><!--bot="Validation"

        S-Display-Name="Concentra" B-Disallow-First-Item="TRUE"

--><select name="Concentra" size="1" style="font-family: Arial;

font-size: 8pt; color: rgb(0,30,128)">

        <option>Concentra</option>

<option value="concentra_1">concentra_1</option>

<option value="concentra_2">concentra_2</option>

<option value="concentra_3">concentra_3</option>

<option value="concentra_4">concentra_4</option>

<option value="concentra_5">concentra_5</option>

<option value="concentra_6">concentra_6</option>

<option value="concentra_7">concentra_7</option>

<option value="concentra_8">concentra_8</option>

<option value="concentra_9">concentra_9</option>

      </select></font><font face="Arial" color="#000000"><small> 

<input type="submit" value="Ok" name="B1" style="font-family: Arial;

font-size: 8pt; color: rgb(0,0,128)"></small></font></p>

      </center>

</BODY>

</HTML>





Message #2 by "Pappas Nikos" <pappas@c...> on Mon, 22 Jan 2001 20:44:58 -0800
I cant say what the problem is but 2 things I thing you should check



1)Try to avoid using your language characters for fields and fieldnames

2)    sql = "SELECT * farmaco.mdb"  hmmmm I am not sure but better use

if Data is number

"SELECT * FROM sometable WHERE sometableFieldName = " & Data

If Data  is a string

"SELECT * FROM sometable WHERE mdbSomeFieldName = '" & Data & "' "



Hope it will help

Nikos


  Return to Index