Forums
This topic is locked
ASP dreamweaver and Access Database help needed
Posted 26 Jul 2005 21:43:45
1
has voted
26 Jul 2005 21:43:45 billy jones posted:
Can any help me with the following or point me to some examples of using Dreamweaver and Access to update the data in an Access database which has several related tables?I want to -
Enter a details in to a table called Video Details - Video ID, video name, video number, video title etc in table_1
And in a second table called Video Location I want Video ID (linked as a one-to-many) video_location_id, location_name
And a third table called Video Category I want Video ID, Category name, category number.
The 3 tables are all linked, so a video can be in more than one category and stored in more than one location.
I am using .asp, dreamweaver and Access. I need some pages in Dreamweaver to do this, I have it all set up in Access, but no luck with dreamweaver so far...
Replies
Replied 26 Jul 2005 23:35:42
26 Jul 2005 23:35:42 Rene Bandsma replied:
Although you can create with Dreamweaver dynamic pages without writing one line of code this is quite difficult to handle and you have to write many code by hand. So if you do not have any experience in ASP you should maybe re-think of another solution.
When you do not have enough knowledge about ASP, SQL and the MS Access database then I'll sugest to make three different inserted with three different pages (to keep it simple to read and to understand what is happening).
1. Create a page with a standard Insert to Record behaviour;
2. Create a followup page that reads the last inserted Id and insert the rest of the form;
3. Create another followup page that reads again the Id and insert the rest in the form.
Good luck!
<hr><b>DMXZone support manager</b><br><a href="www.kousman.nl">Kousman web resellers</a>
When you do not have enough knowledge about ASP, SQL and the MS Access database then I'll sugest to make three different inserted with three different pages (to keep it simple to read and to understand what is happening).
1. Create a page with a standard Insert to Record behaviour;
2. Create a followup page that reads the last inserted Id and insert the rest of the form;
3. Create another followup page that reads again the Id and insert the rest in the form.
Good luck!
<hr><b>DMXZone support manager</b><br><a href="www.kousman.nl">Kousman web resellers</a>
Replied 29 Jul 2005 03:04:14
29 Jul 2005 03:04:14 Raafat Abdul replied:
I understood that you need to insert or update to multiple tables (or even do both from a single submit). If that's the case then it is possible, however you'll need to do the code manually. This example inserts into 2 different tables from one page… I used Oracle here but I don't see any reason why you can't do the same in Access. Take a look at the "Section Insert".
I created 2 tables and 2 pages:
Table_1 contains the fields ID1 as integer, TXT1 as text(varchar).
Table_2 contains the fields ID2 as integer, TXT2 as text(varchar).
___________________
Page1(insert.asp)
<pre id=code><font face=courier size=2 id=code>
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/DBConnection.asp" -->
<%
var MM_editAction = Request.ServerVariables("SCRIPT_NAME"
if (Request.QueryString) {
MM_editAction += "?" + Server.HTMLEncode(Request.QueryString);
}
var MM_abortEdit = false;
var MM_editQuery= " ";
%>
<%
// Begin Section Insert:
// The code to insert into the 2 tables
var myID=Request.Form("ID"
var myTXT=Request.Form("TXT"
if (String(Request("MM_insert") == "form1"
{
var Command1 = Server.CreateObject("ADODB.Command"
Command1.ActiveConnection = MM_DBConnection_STRING;
Command1.CommandText = "INSERT INTO TABLE_1 (ID1, TXT1) VALUES (" + myID + ",'" + myTXT +"' ) ";
Command1.CommandType = 1;
Command1.CommandTimeout = 0;
Command1.Prepared = true;
Command1.Execute();
var Command2 = Server.CreateObject("ADODB.Command"
Command2.ActiveConnection = MM_DBConnection_STRING;
Command2.CommandText = "INSERT INTO TABLE_2 (ID2, TXT2) VALUES (" + myID + ",'" + myTXT +"' ) ";
Command2.CommandType = 1;
Command2.CommandTimeout = 0;
Command2.Prepared = true;
Command2.Execute();
var MM_editRedirectUrl = "display.asp";
if (MM_editRedirectUrl) {Response.Redirect(MM_editRedirectUrl);}
}
// End Section Insert
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form name="form1" method="post" action="<%=MM_editAction%>">
<p>ID:
<input name="ID" type="text" id="ID">
</p>
<p>TXT:
<input name="TXT" type="text" id="TXT">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>
</font id=code></pre id=code>
______________________
Page 2 (display.asp)
<pre id=code><font face=courier size=2 id=code>
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/DBConnection.asp" -->
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_DBConnection_STRING;
Recordset1.Source = "SELECT * FROM TABLE_1 order by ID1";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
%>
<%
var Recordset2 = Server.CreateObject("ADODB.Recordset"
Recordset2.ActiveConnection = MM_DBConnection_STRING;
Recordset2.Source = "SELECT * FROM TABLE_2 order by ID2";
Recordset2.CursorType = 0;
Recordset2.CursorLocation = 2;
Recordset2.LockType = 1;
Recordset2.Open();
var Recordset2_numRows = 0;
%>
<%
var Repeat1__numRows = -1;
var Repeat1__index = 0;
Recordset1_numRows += Repeat1__numRows;
%>
<%
var Repeat2__numRows = -1;
var Repeat2__index = 0;
Recordset2_numRows += Repeat2__numRows;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<table border="1">
<tr>
<td colspan="2"><strong>Table #1 </strong></td>
</tr>
<tr>
<td>ID1</td>
<td>TXT1</td>
</tr>
<% while ((Repeat1__numRows-- != 0) && (!Recordset1.EOF)) { %>
<tr>
<td><%=(Recordset1.Fields.Item("ID1".Value)%></td>
<td><%=(Recordset1.Fields.Item("TXT1".Value)%></td>
</tr>
<%
Repeat1__index++;
Recordset1.MoveNext();
}
%>
</table>
<p> </p>
<table border="1">
<tr>
<td colspan="2"><strong>Table #2 </strong></td>
</tr>
<tr>
<td>ID2</td>
<td>TXT2</td>
</tr>
<% while ((Repeat2__numRows-- != 0) && (!Recordset2.EOF)) { %>
<tr>
<td><%=(Recordset2.Fields.Item("ID2".Value)%></td>
<td><%=(Recordset2.Fields.Item("TXT2".Value)%></td>
</tr>
<%
Repeat2__index++;
Recordset2.MoveNext();
}
%>
</table>
<p> </p>
<p><a href="insert.asp">Insert More</a> </p>
</body>
</html>
<%
Recordset1.Close();
%>
<%
Recordset2.Close();
%>
</font id=code></pre id=code>
Regards,
Raafat
Edited by - Raafat on 29 Jul 2005 03:11:51
I created 2 tables and 2 pages:
Table_1 contains the fields ID1 as integer, TXT1 as text(varchar).
Table_2 contains the fields ID2 as integer, TXT2 as text(varchar).
___________________
Page1(insert.asp)
<pre id=code><font face=courier size=2 id=code>
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/DBConnection.asp" -->
<%
var MM_editAction = Request.ServerVariables("SCRIPT_NAME"
if (Request.QueryString) {
MM_editAction += "?" + Server.HTMLEncode(Request.QueryString);
}
var MM_abortEdit = false;
var MM_editQuery= " ";
%>
<%
// Begin Section Insert:
// The code to insert into the 2 tables
var myID=Request.Form("ID"
var myTXT=Request.Form("TXT"
if (String(Request("MM_insert") == "form1"
{
var Command1 = Server.CreateObject("ADODB.Command"
Command1.ActiveConnection = MM_DBConnection_STRING;
Command1.CommandText = "INSERT INTO TABLE_1 (ID1, TXT1) VALUES (" + myID + ",'" + myTXT +"' ) ";
Command1.CommandType = 1;
Command1.CommandTimeout = 0;
Command1.Prepared = true;
Command1.Execute();
var Command2 = Server.CreateObject("ADODB.Command"
Command2.ActiveConnection = MM_DBConnection_STRING;
Command2.CommandText = "INSERT INTO TABLE_2 (ID2, TXT2) VALUES (" + myID + ",'" + myTXT +"' ) ";
Command2.CommandType = 1;
Command2.CommandTimeout = 0;
Command2.Prepared = true;
Command2.Execute();
var MM_editRedirectUrl = "display.asp";
if (MM_editRedirectUrl) {Response.Redirect(MM_editRedirectUrl);}
}
// End Section Insert
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form name="form1" method="post" action="<%=MM_editAction%>">
<p>ID:
<input name="ID" type="text" id="ID">
</p>
<p>TXT:
<input name="TXT" type="text" id="TXT">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>
</font id=code></pre id=code>
______________________
Page 2 (display.asp)
<pre id=code><font face=courier size=2 id=code>
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/DBConnection.asp" -->
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_DBConnection_STRING;
Recordset1.Source = "SELECT * FROM TABLE_1 order by ID1";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
%>
<%
var Recordset2 = Server.CreateObject("ADODB.Recordset"
Recordset2.ActiveConnection = MM_DBConnection_STRING;
Recordset2.Source = "SELECT * FROM TABLE_2 order by ID2";
Recordset2.CursorType = 0;
Recordset2.CursorLocation = 2;
Recordset2.LockType = 1;
Recordset2.Open();
var Recordset2_numRows = 0;
%>
<%
var Repeat1__numRows = -1;
var Repeat1__index = 0;
Recordset1_numRows += Repeat1__numRows;
%>
<%
var Repeat2__numRows = -1;
var Repeat2__index = 0;
Recordset2_numRows += Repeat2__numRows;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<table border="1">
<tr>
<td colspan="2"><strong>Table #1 </strong></td>
</tr>
<tr>
<td>ID1</td>
<td>TXT1</td>
</tr>
<% while ((Repeat1__numRows-- != 0) && (!Recordset1.EOF)) { %>
<tr>
<td><%=(Recordset1.Fields.Item("ID1".Value)%></td>
<td><%=(Recordset1.Fields.Item("TXT1".Value)%></td>
</tr>
<%
Repeat1__index++;
Recordset1.MoveNext();
}
%>
</table>
<p> </p>
<table border="1">
<tr>
<td colspan="2"><strong>Table #2 </strong></td>
</tr>
<tr>
<td>ID2</td>
<td>TXT2</td>
</tr>
<% while ((Repeat2__numRows-- != 0) && (!Recordset2.EOF)) { %>
<tr>
<td><%=(Recordset2.Fields.Item("ID2".Value)%></td>
<td><%=(Recordset2.Fields.Item("TXT2".Value)%></td>
</tr>
<%
Repeat2__index++;
Recordset2.MoveNext();
}
%>
</table>
<p> </p>
<p><a href="insert.asp">Insert More</a> </p>
</body>
</html>
<%
Recordset1.Close();
%>
<%
Recordset2.Close();
%>
</font id=code></pre id=code>
Regards,
Raafat
Edited by - Raafat on 29 Jul 2005 03:11:51