INSERT-problem (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


psoo -> INSERT-problem (9/26/2005 18:23:38)

I will insert into a new Access-table (named surf) the name, date and time when the members of my club make a connection to the memberpages.
I tried to insert the "INSERT INTO code" but it don't work

Where do i insert this "insertcode"
INSERT INTO surf (lastname, firstname, date, time)
VALUES (' ::lastname::' ?????? ,' ::firstname::'?????? , date(), time())
into the selectcode below ? - in this code (below) i select the name of the 'surfer' to make a welcome greet - i will put his lastname and firstname into the new table (surf)

<!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT name,lastname FROM LEDEN WHERE (LedendNr=::uid::)"
fp_sDefault="uid="
fp_sNoRecords="<tr><td colspan=2 align=left width=""100%"">Geen records geretourneerd.</td></tr>"
fp_sDataConn="Connexion"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="firstname"
fp_sMenuValue="firstname"
fp_iDisplayCols=2
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->

<b><font color="#C10000">
<%Dim dtmHour
dtmHour = Hour(Now())%>

<%If dtmHour >= 6 And dtmHour < 12 Then
Response.Write "Good Morning"
ElseIf dtmHour >= 12 And dtmHour < 19 Then
Response.Write "Good Afternoon"
ElseIf dtmHour >= 19 And dtmHour < 23 Then
Response.Write "Good Evening"
Else
Response.Write "Good Night"
End If%>
<%=FP_FieldVal(fp_rs,"firstname")%>,</b></font>
<!--#include file="_fpclass/fpdbrgn2.inc"-->
<p style="margin-top: 0; margin-bottom: 0"> </p>

Thanks for the hints

Pol




Spooky -> RE: INSERT-problem (9/26/2005 19:01:56)

Date and time are reserved words:

INSERT INTO surf (lastname, firstname, [date], [time])




psoo -> RE: INSERT-problem (9/27/2005 13:25:04)

I know that these words are keyword ijn English but not in my language....

My question / problem is
quote:

Where and how do i insert this "insertcode"


Thanks

Pol




Spooky -> RE: INSERT-problem (9/27/2005 19:08:08)

Can you just explain why you would take the existing first / last name into a new table?
Is this to track that the user has been at the site and when?




psoo -> RE: INSERT-problem (9/27/2005 20:34:01)

Yes, that's exactly why I will do this.

Pol




Spooky -> RE: INSERT-problem (9/27/2005 20:55:57)

Ideally you would just track the userid, but otherwise, assign the values to a variable

eg :

 Response.Write "Good Night"
End If%>

<%firstname = FP_FieldVal(fp_rs,"firstname")%>
<%lastname = FP_FieldVal(fp_rs,"lastname")%>

<%=FP_FieldVal(fp_rs,"firstname")%>,</b></font>


Then add another DRW below this one, and just use insert code you have above (with the following changes)

INSERT INTO surf (lastname, firstname, [date], [time])
VALUES ('"&LastName&"','"&firstname&"', date(), time())









Spooky -> RE: INSERT-problem (9/28/2005 18:21:50)

To ensure you get the "firstname" (and all values you need) it would need to be included in the first SQL string - otherwise it would still be blank




psoo -> RE: INSERT-problem (9/29/2005 18:16:01)

Spooky, I don't understand very good what you mean in your last reply - is it this : in the first SQL string, I think that the two fieldnames are included, as you can see (in my earlier message and) hereafter :

fp_sQry="SELECT voornaam,familienaam FROM LEDEN WHERE (LedendNr=::uid::)"
fp_sDefault="uid="
...
My surf-table (=the target tabel) works correct when I make a test-select-query.

What can be still wrong in the insert codes ?

Thanks
Pol




Spooky -> RE: INSERT-problem (9/29/2005 20:24:02)

Have you tried :

 fp_sQry="INSERT INTO surf (familienaam,voornaam,[datum],[tijd]) VALUES ('"&familienaam&"','"&voornaam&"', date(), time())" 




psoo -> RE: INSERT-problem (9/30/2005 19:52:23)

Have you tried :

fp_sQry="INSERT INTO surf (familienaam,voornaam,[datum],[tijd]) VALUES ('"&familienaam&"','"&voornaam&"', date(), time())"[/quote]


Yes I tried this code but it do not work - this is my code

<!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="INSERT INTO surf (familienaam,voornaam,[datum],[tijd]) VALUES ('"&familienaam&"','"&voornaam&"', date(), time())"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=16 align=left width=""100%"">Geen records geretourneerd.</td></tr>"
fp_sDataConn="XYZ"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<!--#include file="_fpclass/fpdbrgn2.inc"-->
</tbody>

It is apparently very difficult to let work the FontPage Insert-code in combination with the Select-code (see my earlier message).
That must nevertheless succeed but how ...

Thanks for hints
Pol




Spooky -> RE: INSERT-problem (10/1/2005 1:23:07)

Could you post your whole code here?
Have you ensured the 2 DRW's are completely seperate?




psoo -> RE: INSERT-problem (10/1/2005 19:32:20)

The SELECT + INSERT-code

<body topmargin="10">
<div align="left">
<table border="0" cellpadding="0" cellspacing="0" width="600">
<tr>
<td width="20"></td>
<td width="550"><font face="Arial" size="3">
<table width="550"><tr><td>
<tbody>
<!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="SELECT voornaam,familienaam FROM LEDEN WHERE (LedendNr=::uid::)"
fp_sDefault="uid="
fp_sNoRecords="<tr><td colspan=2 align=left width=""100%"">Geen records geretourneerd.</td></tr>"
fp_sDataConn="XYZ"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="voornaam"
fp_sMenuValue="voornaam"
fp_iDisplayCols=2
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->

<b><font color="#C10000">
<%Dim dtmHour
dtmHour = Hour(Now())%>

<%If dtmHour >= 6 And dtmHour < 12 Then
Response.Write "Goede morgen "
ElseIf dtmHour >= 12 And dtmHour < 19 Then
Response.Write "Goede middag "
ElseIf dtmHour >= 19 And dtmHour < 23 Then
Response.Write "Goede avond "
Else
Response.Write "Goede nacht "
End If%>

<%voornaam = FP_FieldVal(fp_rs,"voornaam")%>
<%familienaam = FP_FieldVal(fp_rs,"familienaam")%>

<%=FP_FieldVal(fp_rs,"voornaam")%>,</b></font>
<!--#include file="_fpclass/fpdbrgn2.inc"-->
<p style="margin-top: 0; margin-bottom: 0"> </p>


<!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="INSERT INTO surf (familienaam,voornaam,[datum],[tijd]) VALUES ('"&familienaam&"','"&voornaam&"', date(), time())"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=16 align=left width=""100%"">Geen records geretourneerd.</td></tr>"
fp_sDataConn="XYZ"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<!--#include file="_fpclass/fpdbrgn2.inc"-->
</tbody>


</table>
<table>
....

Thanks for the hint.
Pol




Spooky -> RE: INSERT-problem (10/1/2005 21:14:18)

Does it write this value to the web page currently?

<%=FP_FieldVal(fp_rs,"voornaam")%>

If so, directly after it, can you add this code, and does it also write to the page?

<%=FP_FieldVal(fp_rs,"voornaam")%>, <%=familienaam%> </b></font>





psoo -> RE: INSERT-problem (10/2/2005 10:57:34)

The code

<%voornaam = FP_FieldVal(fp_rs,"voornaam")%>
<%familienaam = FP_FieldVal(fp_rs,"familienaam")%>
<%=FP_FieldVal(fp_rs,"voornaam")%>, <%=familienaam%> </b></font>

gives the following result : "Goede morgen Pol,"

This could mean that the two variables (<%voornaam= and <%=familienaam=) have no contents ?

I do not understand also why the independent variables date() and time() nevertheless are not filled in in the table surf, because a test of the separate insert code (with the following code) is OKAY: the four fields of the table Surf are filled in

<!--#include file="_fpclass/fpdblib.inc"-->
<%
fp_sQry="INSERT INTO surf (familienaam,voornaam,[datum],[tijd]) VALUES ('TEST','TEST1', date(), time())"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=16 align=left width=""100%"">Geen records geretourneerd.</td></tr>"
fp_sDataConn="XYZ"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<!--#include file="_fpclass/fpdbrgn2.inc"-->

Thanks for the hint,

Pol




Spooky -> RE: INSERT-problem (10/3/2005 3:21:02)

It seems for some reason they are blank.

Try this?

<%voornaam = "test1"%>
<%familienaam = "test2"%>




psoo -> RE: INSERT-problem (10/3/2005 17:28:53)

Also with the "test"codes , there is no 'movement' in the Surf table.
The variables remain blank. Strange reason with a difficult solution ?
I am strongly interested how this problem can be solved.

Otherwise, in an earlier message -dd. 9/27/2005 20:55:57- you (Spooky) wrote : "Ideally you would just track the userid, but otherwise, assign the values to a variable" - Is this (track the userid) perhaps an other and easier solution ?

Thanks

Pol

I tested today this code (after the SELECT-code), but without using the variables <%voornaam and <%familienaam.
fp_sQry="INSERT INTO surf (familienaam,voornaam,[datum],[tijd]) VALUES ('test3','test4', date(), time())"
However without good result.

This is very strange because I tested earlier - successfully - these INSERT-code without the preceding SELECT-code.

Is it possible that the problem is situated in the passage of SELECT code to INSERT code or in the bad? combination / passage SELECT- and INSERT-code ?

Pol




Spooky -> RE: INSERT-problem (10/5/2005 16:27:31)

The only other idea that I had, is there any code using "ON ERROR RESUME NEXT" on this page that is perhaps masking an error?
Other than that - no idea whats happening [&o]




psoo -> RE: INSERT-problem (10/7/2005 19:06:25)

My problem is solved.
I tested all the time a (duplicated) file that was not linked - excuse me for this stupid (newbee-)error. It works fine now. Thanks for the tips / updates.

Now I have the startime (when the surfer enters from the public pages into the memberpages). Is it also possible to obtain the 'stoptime' = when he leaves the memberpages (and perhaps which memberpages he has visited) ? I don't know the 'way' to do this.
Thanks for a hint.
Pol






Spooky -> RE: INSERT-problem (10/8/2005 0:19:15)

Theres no real "stop" time, as the server doesnt know how long the user is there.
The only thing you can do, is create a stop time that equals the session time out (usually 20 minutes)
If no activity is detected, then assume the user has gone.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.09375