Imar,
Thank you for your reply. I understand that I am not very clear in my post and will try to explain myself better.
I have an access database with a lot of tables and am using Dreamweaver to create a web interface.
The primary use of the web interface is for data entry at this stage.
To start, my default page is a search page. The user enters the 'ID' to query if the 'ID' exists in one table.
On submit to the search, it opens a new page where a summary of the record is shown (or if there's no record a line says "would you like to create a new record.."). There is a button on this summary page if the user wants to edit the record. This button redirects to a new page bound to one table in the database. The 'ID' all along is passed from page to page via a hidden field. .
On that new edit page, the user can update the record. There is also a ddl wich redirects to different pages depending on the choice made.
On submit, it works, the table bound to the database is updated. and the user is redirected to the right page (depending on that choice made on the ddl) and another page bound to another table in the database is open.
That's where i am having trouble. On this new page, there's a new dataset, the record may or may not exists. The user needs to fill the form and submit and again he will be redirect to a new page with another dataset bound.
Anyway, passing the 'ID' from one page to another works fine. My problem is how to tell the server to either update or insert.
So far I can only do one at a time:
If i choose mm_insert, the table get a new record but I am getting duplicates (and yes, there's no primary key...)
If i choose mm_update. it doesn't work 'cos sometimes there's no records in that table.
With Dreamweaver, i can use mm_update or mm_insert
What I am trying to do is to write some type of statement like what you've written.
If Request.QueryString("ID") <> "" Then
' Update
Else
'New
End If
but i do not know how to properly write it and where.
As for some code:
<%@ Page Language="
VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicK eyToken=836f606ede05d46a,culture=neutral" %>
<MM:Insert
runat="server"
CommandText='<%# "INSERT INTO AllPCsTerms (AllPCsCabledTocommsR, AllPCsCnntoWallorHub, AllPCsDeviceType, AllPCsFNLOC, AllPCsIfISPthenISPName, AllPCsInternetConn, AllPCsIT_Number, AllPCsKbrdSwipeUsed, AllPCsModem, AllPCsMouseUsed, AllPCsNetconnOrCable, AllPCsOfficeMacrosUsed, AllPCsOS, AllPCsOthCbleType, AllPCsPortNoOnWall, ALLPCsSSTPerformed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connAudit") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connAudit") %>'
Expression='<%# Request.Form("MM_insert") = "form1" %>'
CreateDataSet="false"
Debug="true"
><Parameters>
<Parameter Name="@AllPCsCabledTocommsR" Value='<%# IIf((Request.Form("cabledtocommsr") <> Nothing), Request.Form("cabledtocommsr"), "") %>' Type="WChar" />
<Parameter Name="@AllPCsCnntoWallorHub" Value='<%# IIf((Request.Form("ConnWall") <> Nothing), Request.Form("ConnWall"), "") %>' Type="WChar" />
<Parameter Name="@AllPCsDeviceType" Value='<%# IIf((Request.Form("DeviceType") <> Nothing), Request.Form("DeviceType"), "") %>' Type="WChar" />
<Parameter Name="@AllPCsFNLOC" Value='<%# IIf((Request.Form("FNLOC") <> Nothing), Request.Form("FNLOC"), "") %>' Type="WChar" />
<Parameter Name="@AllPCsIfISPthenISPName" Value='<%# IIf((Request.Form("ISPname") <> Nothing), Request.Form("ISPname"), "") %>' Type="WChar" />
<Parameter Name="@AllPCsInternetConn" Value='<%# IIf((Request.Form("ddlIntConn") <> Nothing), Request.Form("ddlIntConn"), "") %>' Type="WChar" />
<Parameter Name="@AllPCsIT_Number" Value='<%# IIf((Request.Form("ITNumber") <> Nothing), Request.Form("ITNumber"), "") %>' Type="WChar" />
<Parameter Name="@AllPCsKbrdSwipeUsed" Value='<%# IIf((Request.Form("keyboardswipe") <> Nothing), Request.Form("keyboardswipe"), "") %>' Type="Boolean" />
<Parameter Name="@AllPCsModem" Value='<%# IIf((Request.Form("ddlmodem") <> Nothing), Request.Form("ddlmodem"), "") %>' Type="WChar" />
<Parameter Name="@AllPCsMouseUsed" Value='<%# IIf((Request.Form("mouseused") <> Nothing), Request.Form("mouseused"), "") %>' Type="Boolean" />
<Parameter Name="@AllPCsNetconnOrCable" Value='<%# IIf((Request.Form("netwconn") <> Nothing), Request.Form("netwconn"), "") %>' Type="WChar" />
<Parameter Name="@AllPCsOfficeMacrosUsed" Value='<%# IIf((Request.Form("officemacro") <> Nothing), Request.Form("officemacro"), "") %>' Type="WChar" />
<Parameter Name="@AllPCsOS" Value='<%# IIf((Request.Form("OSlink") <> Nothing), Request.Form("OSlink"), "") %>' Type="WChar" />
<Parameter Name="@AllPCsOthCbleType" Value='<%# IIf((Request.Form("othercable") <> Nothing), Request.Form("othercable"), "") %>' Type="WChar" />
<Parameter Name="@AllPCsPortNoOnWall" Value='<%# IIf((Request.Form("pcwallport") <> Nothing), Request.Form("pcwallport"), "") %>' Type="WChar" />
<Parameter Name="@ALLPCsSSTPerformed" Value='<%# IIf((Request.Form("sstperformed") <> Nothing), Request.Form("sstperformed"), "") %>' Type="Boolean" />
</Parameters>
</MM:Insert>
<MM:DataSet
id="dsAllPCsTerms"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connAudit") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connAudit") %>'
CommandText='<%# "SELECT * FROM AllPCsTerms WHERE AllPCsIT_Number = ?" %>'
Debug="true"
>
<Parameters>
<Parameter Name="@AllPCsIT_Number" Value='<%# IIf((Request.QueryString("ITNumber") <> Nothing), Request.QueryString("ITNumber"), "") %>' Type="WChar" />
</Parameters>
</MM:DataSet>
<MM:DataSet
id="connectedtowall"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connAudit") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connAudit") %>'
CommandText='<%# "SELECT * FROM connectedtowall" %>'
Debug="true"
></MM:DataSet>
<MM:DataSet
id="netwconntype"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connAudit") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connAudit") %>'
CommandText='<%# "SELECT * FROM NetworkConnectType" %>'
Debug="true"
></MM:DataSet>
<MM:DataSet
id="OffMacros"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connAudit") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connAudit") %>'
CommandText='<%# "SELECT * FROM OfficeMacros" %>'
Debug="true"
></MM:DataSet>
<MM:DataSet
id="dsmodem"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connAudit") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connAudit") %>'
CommandText='<%# "SELECT * FROM modem" %>'
Debug="true"
></MM:DataSet>
<MM:DataSet
id="dsIntConn"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connAudit") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connAudit") %>'
CommandText='<%# "SELECT * FROM InternetConnection" %>'
Debug="true"
></MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<script language="
VB" runat="server">
Sub SubmitBtn_Click(sender As Object, e As EventArgs)
Session("ddlmodem")=Request("ddlmodem")
Session("SerialNumber")=Request("SerialNumber")
Session("DeviceType")=Request("DeviceType")
Session("netwconn")=Request("netwconn")
Session("pcwallport")=Request("pcwallport")
Session("othercable")=Request("othercable")
Session("cabledtocommsr")=Request("cabledtocommsr" )
Session("keyboardswipe")=Request("keyboardswipe")
Session("mouseused")=Request("mouseused")
Session("OS")=Request("OS")
Session("sstperformed")=Request("sstperformed")
Session("officemacro")=Request("officemacro")
Session("ConnWall")=Request("ConnWall")
Session("ddlIntConn")=Request("ddlIntConn")
Session("ISPname")=Request("ISPname")
Session("hostswitching")= Request("hostswitching")
Session("airlines")=Request("airlines")
Response.Redirect(OSlink.SelectedItem.Value)
End Sub
</script>
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
<title>AllPCs_Terminals</title><form runat='server' method='POST' name='form1' class="style1">
<table width="655" border=0 align=CENTER cellpadding=0 cellspacing=0 bgcolor=#6699CC>
<tr>
<th height="37" colspan=3 align=CENTER>All PCs and Laptops
<input name="ITNumber" type="text" id="ITNumber" value="<%= Session("ITNumber") %>" readonly="true"></th>
</tr>
<tr>
<td width="259">FNLOC</td>
<td colspan="2"><input name="FNLOC" type="text" id="FNLOC" > </td>
</tr>
<tr>
<td>Connected to </td>
<td colspan="2"><asp:DropDownList ID="ConnWall" DataSource="<%# connectedtowall.DefaultView %>" DataTextField="connected to" DataValueField="connected to" runat="server"></asp:DropDownList></td>
</tr>
<tr>
<td>Wall Port </td>
<td colspan="2"><input name="pcwallport" type="text" id="pcwallport"></td>
</tr>
<tr>
<td>Network Connection or Cable Type</td>
<td width="152"> <asp:DropDownList ID="netwconn" DataSource="<%# netwconntype.DefaultView %>" DataTextField="NetworkConnectType" DataValueField="NetworkConnectType" runat="server"></asp:DropDownList>
If Other </td>
<td width="244"><input name="othercable" type="text" id="othercable"></td>
</tr>
<tr>
<td>Cabled to (Comms Room Name) </td>
<td colspan="2"><input name="cabledtocommsr" type="text" id="cabledtocommsr"></td>
</tr>
<tr>
<td>Keyboard Swipe Used </td>
<td colspan="2"><asp:CheckBox ID="keyboardswipe" Text='<%= Session("keyboardswipe") %>' runat="server" Enabled="true" /></td>
</tr>
<tr>
<td>Mouse Used </td>
<td colspan="2"><asp:CheckBox ID="mouseused" Text='<%= Session("mouseused") %>' runat="server" Enabled="true" /></td>
</tr>
<tr>
<td>Operating System</td>
<td colspan="2"><asp:DropDownList
OnSelectedIndexChanged="SubmitBtn_Click" ID="OSlink" runat="server">
<asp:ListItem value="">Choose</asp:ListItem>
<asp:ListItem value="/DOSorOS2.aspx">DOS</asp:ListItem>
<asp:ListItem value="/DOSorOS2.aspx">OS2</asp:ListItem>
<asp:ListItem value="/site2.aspx">Win3.11</asp:ListItem>
<asp:ListItem value="/sessions.aspx">Win9x</asp:ListItem>
<asp:ListItem value="/sessions.aspx">Win2k</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>SST Performed </td>
<td colspan="2"><asp:CheckBox ID="sstperformed" Text='<%= Session("sstperformed") %>' runat="server" Enabled="true" /></td>
</tr>
<tr>
<td>Office Macros Used </td>
<td colspan="2"><asp:DropDownList ID="officemacro" DataSource="<%# OffMacros.DefaultView %>" DataTextField="OfficeMacros" DataValueField="OfficeMacros" runat="server"></asp:DropDownList></td>
</tr>
<tr>
<td>Modem</td>
<td colspan="2"><asp:DropDownList ID="ddlmodem" DataSource='<%# dsmodem.DefaultView %>' DataTextField="modem" DataValueField="modem" runat="server"></asp:DropDownList></td>
</tr>
<tr>
<td>Internet Connection </td>
<td colspan="2"> <asp:DropDownList ID="ddlIntConn" DataSource="<%# dsIntConn.DefaultView %>" DataTextField="InternetConnection" DataValueField="InternetConnection" runat="server"></asp:DropDownList>
If ISP, which one
<input name="ISPname" type="text" id="ISPname"></td></tr>
<tr>
<td>Host Switching </td>
<td colspan="2"><asp:CheckBox ID="hostswitching" Text='<%= Session("hostswitching") %>' runat="server" /></td>
</tr>
<tr>
<td>Airlines</td>
<td colspan="2"><input name="airlines" type="text" id="airlines"></td>
</tr>
<tr>
<td> </td>
<td colspan="2"><asp:Button ID="Submit" runat="server" Text="Submit" /></td>
</tr>
<tr>
<td align=CENTER colspan=3> </table>
<input name="DeviceType" type="hidden" id="DeviceType" value='<%= Session("DeviceType") %>'>
<input type="hidden" name="MM_insert" value="form1">
</form>
This page only has MM_insert. I can also create a MM_update but as I said, I do not know how to write the statement if... then if... then end if...
Thanks so much for taking the time to read this.
( I have another issue with the ddl... I don't seem to be able to capture the right input. So far, the database is updated with the link not with the value of the field... for example, if the user chooses DOS, the database is updated with /DosorOS2.aspx)