Design Time Controls and SQL

Results 1 to 4 of 4

Thread: Design Time Controls and SQL

  1. #1
    fred Guest

    Default Design Time Controls and SQL

    I recently switched over to visual interdev 6.0 to develop a web application, and starting experimenting with DTCs for recorset navigation. I build my own sql statements or use the sql builder and everything works fine as long as I use literals, like<BR><BR>SELECT Post_ID, Poster, WinTeam, LosingTeam, strDate, <BR> Post_Ref<BR>FROM ClanPostLog<BR>WHERE (Table_ID = 3) AND <BR> (WinTeam = &#039someteam&#039) OR<BR> (LosingTeam =&#039someteam&#039)<BR>ORDER BY Post_ID DESC<BR><BR><BR>The problem is I want to use a string variable, like a session<BR>object--Session ("Team")-- instead of a literal, and I can&#039t get<BR>it to work. I&#039ve scoured the documentation, but can&#039t find references to using variables or asp objects with the query builder. Yes, I can manually code this in vbscript using a text editor, but the whole point of using visual interdev is to simplify development, and I want to integrate recordset DTCs with the web application&#039s state variables.<BR>

  2. #2 Guest

    Default RE: Design Time Controls and SQL

    To incorporate ASP variables in to your query you just need to replace the literals with variables like this:<BR><BR>&#060;% Dim SqlQryStr,someteam ,ID<BR>SqlQryStr = "SELECT Post_ID, Poster, WinTeam, LosingTeam, strDate, Post_Ref FROM ClanPostLog WHERE (Table_ID = " & ID & ") AND (WinTeam = &#039" & someteam & "&#039) OR (LosingTeam =&#039" & someteam & "&#039) ORDER BY Post_ID DESC"<BR>%&#062;<BR>You would presumably retreive the value of the variables someteam and ID. I have assumed that the db fields WinTeam and LosingTeam are text type, and Table_ID is numeric.<BR><BR>

  3. #3
    fred Guest

    Default RE: Design Time Controls and SQL

    Well, thanx for the response, but I know how how to concatenate<BR>strings in vbscript and jscript. The problem is that the DTC is written in jscript , and no matter how I try to format the sql string in sql builder, such as<BR><BR>SELECT Post_ID, Poster, WinTeam, LosingTeam, strDate, <BR> Post_Ref<BR>FROM ClanPostLog<BR>WHERE (Table_ID = 3) AND <BR> (WinTeam = &#039" + strTeam + "&#039) OR<BR> (LosingTeam =&#039" + strTeam + "&#039)<BR>ORDER BY Post_ID DESC<BR><BR>Then I go to the code manually and in the _InitRecordSet1 function and add<BR><BR>var strTeam = Session (&#039Team&#039);<BR><BR>all I get is an empty recordset at run time. Like I said in my earlier post, I have experience in asp, and could do this in vbscript, but I&#039m fairly new to visual interdev, and i&#039m interested if anyone else knows how to easily integrate DTC recordsets with ASP objects, like the session object.<BR><BR>

  4. #4
    fred Guest

    Default Never Mind, fixed it

    you need to add a new data command, create a parametrized query,<BR>point the recordset to that command, then add a Sub Recordset1_onbeforeopen() routine that replaces the parameters<BR>with the Session object at run time. Apparently, you can&#039t just<BR>concatenate an sql string with asp variables at design time using DTCs. Oh well.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts