Forum Moderators: open

Message Too Old, No Replies

IF Conditional

Access Database

         

Larry9935

2:28 pm on Aug 27, 2007 (gmt 0)

10+ Year Member



I did not write this webpage but was asked to modify it.
I am wanting to do a conditional on a data field in access.
The webpage I have is writing out the information for the database but I can't find where it is reading it at.
I believe ( could be wrong about this ) once I find the read statement I can write the if conditional to do a comparison.

This is what I have found on the webpage

<MM:DataSet
id="DataSet1"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_OCG") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_OCG") %>'
CommandText='<%# "SELECT * FROM Precincts WHERE ID =?" %>'
Debug="true"
>
<Parameters>
<Parameter Name="@ID" Value='<%# IIf((Request.QueryString("ID") <> Nothing), Request.QueryString("ID"), "") %>' Type="Integer" />
</Parameters></MM:DataSet>

==============

<table width="99%" align="center"><tr><td valign="top" class="answer"><br />
<form id="vtrchk" name="vtrchk" method="post" runat="server" OnClick="SubmitButton_Click">
<table width="99%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="60"><div align="center">
<table width="75%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td><div align="right">Address Entered:</div></td>
<td><%# DataSet1.FieldValue("LABEL", Container) %></td>
</tr>
<tr>
<td><div align="right">City:</div></td>
<td><%# DataSet1.FieldValue("CITY", Container) %></td>
</tr>
<tr>
<td><div align="right">Zip:</div></td>
<td><%# DataSet1.FieldValue("ZIPCODE", Container) %></td>
</tr>
<tr>
<td height="50" colspan="2" valign="bottom"><div align="center">Based on this information, your voting precinct is:</div></td>
</tr>
<tr>
<td colspan="2"><div align="center" class="style1"><%# DataSet1.FieldValue("POLL_PL", Container) %>

<br /><br /><%# DataSet1.FieldValue("POLL_LOC", Container) %></div><br /><br /></td>
</tr>
</table>
<center>

<input name="Button" value="GET MAP OF PRECINCT LOCATION" type=button onClick="getMap()">
</center>


</div></td>
</tr>

Thanks

UFfan

1:22 pm on Aug 28, 2007 (gmt 0)

10+ Year Member



This SQL query requests the data from the access database table Precincts.
SELECT * FROM Precincts WHERE ID =?

Parameters @ID determents the Id
your parameter is determined by the QueryString("ID")

So your SQL query says - Select everything from table Precincts where id equals @ID

Write to page
DataSet1.FieldValue("LABEL", Container)
DataSet1.FieldValue("ZIPCODE", Container)
DataSet1.FieldValue("POLL_LOC", Container)

I am not sure what you mean by a conditional on a data field in access.

Do you mean after the data is returned such as
If DataSet1.FieldValue("ZIPCODE", Container) = "32323" Then ...

or Do you mean add a condition in the SQL query such as
SELECT * FROM Precincts WHERE (ID =?) AND (ZIPCODE = '32323')