Print Page | Close Window

insert SQL

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=795
Printed Date: 28 March 2026 at 10:23pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: insert SQL
Posted By: tomasz
Subject: insert SQL
Date Posted: 07 March 2003 at 7:18am

When I insert this in a ASP page...

<%SQL = "SELECT Column1" _ & " FROM Table1 WHERE ID=6" >

... it works but when I want to insert other data from thesame SQL Database but from another table,......

<%SQL = "SELECT Column2" _ & " FROM Table2 WHERE ID=6" >

... it doesn't work anymore.

Can you only use one or is there a solution??




Replies:
Posted By: michael
Date Posted: 07 March 2003 at 9:40am
Both SQL queries are OK, you said you are inserting, where? What is the error. It doesen't work is not an error message I know. Try to be a little more specific what you are doing.


Posted By: tomasz
Date Posted: 07 March 2003 at 11:14am

This is my code:

<html>
<head>
<title>Spelers</title>
<%
dbq = Server.MapPath("/dbase/stats.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);" _
            & "DBQ=" & dbq
%>
</head>
<body>
<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC">
  <tr>
    <td width="100%">
      <table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
                <td width="100%"><b>Doelpunten:&nbsp;</b><%
SQL = "SELECT Doelpunten, ID" _
      & " FROM Topscorer WHERE ID=6"
' and we get our recordset!
Set RS = Conn.Execute( SQL )
If RS.EOF Then
    Response.Write "0"
    Response.End
End If

%>
<%
    Response.Write _
    "" & RS("Doelpunten") & "" & _
%>
</td>
</tr>
<tr>
<td width="100%"><b>Kaarten:</b>
</td>
</tr>
<tr>
<td width="100%"><%
SQL = "SELECT Naam, Kaart, Wedstrijd, Datum" _
      & " FROM Kaartenlast WHERE ID=6"
' and we get our recordset!
Set RS = Conn.Execute( SQL )
If RS.EOF Then
    Response.Write "geen kaarten gekregen"
    Response.End
End If

%>
<TABLE Width='100%' Border=0 bordercolor=#FFFF99 CellPadding=0 CellSpacing=0 bgColor=#FFFFCC>
<%
Do Until RS.EOF
    Response.Write _
   "<TR>" & _
    "    <TD align=""center""><img src=""" & RS("Kaart") & """></TD>" & _
    "    <TD align=""center"">" & RS("Wedstrijd") & "</TD>" & _
    "    <TD align=""center"">" & FormatDateTime( RS("Datum"), vbShortDate ) & "</TD>" & _
    "</TR>" & vbNewLine 
    RS.MoveNext
Loop
%>
<%
conn.close
set conn = Nothing
%>
</TABLE></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
</body>
</html>

This is my code when I choose 'view source' in my browser:

<html>
<head>
<title>Spelers</title>
</head>

<body>
<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#FFFFCC">
  <tr>
    <td width="100%">
      <table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
                <td width="100%"><b>Doelpunten:&nbsp;</b>0

It just stops here. Like you see, I'm not getting an error but the second part of my page doesn't appear.



Posted By: michael
Date Posted: 07 March 2003 at 12:02pm
Well if this is all you see it means that RS.EOF is TRUE so you need to check you sql script with the db, something seems wrong there.


Posted By: tomasz
Date Posted: 07 March 2003 at 2:49pm

I 've found the problem : when the page doesn't find information (in my page where the column 'ID' doesn't have a '6') it stops working. So the problem is in :
If RS.EOF Then
    Response.Write "geen kaarten gekregen"
    Response.End
End If

Is there another way to to display something on the page when the page doesn't find the information??



Posted By: tomasz
Date Posted: 07 March 2003 at 3:03pm
YES!! I've found it. I had to remove 'Response.End'. THNX michael for your responses.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net