Thread View: borland.public.delphi.database.dotnet
7 messages
7 total messages
Started by Benedictum
Thu, 08 Feb 2007 18:48
Help with ASP translation
Author: Benedictum
Date: Thu, 08 Feb 2007 18:48
Date: Thu, 08 Feb 2007 18:48
220 lines
5856 bytes
5856 bytes
I was asked to revamped an ASP web page using Delphi2006. I have the
following code:
//*****************
<%
Dim xConn
Dim xrs
Dim strConn
Dim strsql
Dim sPrevCategory
' Get connection string
strConn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=\\premfs2\sites\Premium7\bgr5678\database\diamond.mdb;Persist
Security Info=False"
' Open connection to the database
set xConn = Server.CreateObject("ADODB.Connection")
xConn.Open strConn
' Build the query
strsql = "SELECT * FROM Event LEFT JOIN EventCategory ON
[Event].[CategoryCd]=[EventCategory].[CategoryCd] WHERE Now() BETWEEN
EventDateStart AND EventDateEnd ORDER BY [SortSeq], [EventDate1]"
' Open recordset
set xrs = Server.CreateObject("ADODB.Recordset")
xrs.Open strsql, xConn
' Loop out the HTML
sPrevCategory = ""
Do While (NOT xrs.EOF)
if sPrevCategory <> xrs("EventCategory.Title") then
sPrevCategory = xrs("EventCategory.Title")
Response.Write("<tr><td class=""ddsGridHdr""><h3>")
Response.Write xrs("EventCategory.Title")
Response.Write("</h3>")
if len(xrs("EventCategory.Description")) > 0 Then
Response.Write("<span class=""ddsFootnote"">")
Response.Write xrs("EventCategory.Description")
Response.Write("</span>")
end if
Response.Write("</td></tr>")
end if
Response.Write("<tr><td class=""ddsGridTag""><h4>")
Response.Write xrs("Event.Title")
Response.Write("</h4>")
if len(xrs("Description")) > 0 Then
Response.Write("<p class=""ddsIndentedParagraph"">")
Response.Write xrs("Description")
Response.Write("</p>")
end if
Response.Write("<ul>")
if len(xrs("Host")) > 0 Then
Response.Write("<li>")
Response.Write xrs("Host")
Response.Write("</li>")
end if
if len(xrs("TimeDescription")) > 0 Then
Response.Write("<li>")
Response.Write xrs("TimeDescription")
Response.Write("</li>")
end if
if len(xrs("PriceDescription")) > 0 Then
Response.Write("<li>")
Response.Write xrs("PriceDescription")
Response.Write("</li>")
end if
if len(xrs("Bullet1")) > 0 Then
Response.Write("<li>")
Response.Write xrs("Bullet1")
Response.Write("</li>")
end if
if isdate(xrs("EventDate1")) Then
Response.Write("<li>")
Response.Write FormatDateTime(xrs("EventDate1"),1)
Response.Write("</li>")
end if
if len(xrs("Bullet2")) > 0 Then
Response.Write("<li>")
Response.Write xrs("Bullet2")
Response.Write("</li>")
end if
if isdate(xrs("EventDate2")) Then
Response.Write("<li>")
Response.Write FormatDateTime(xrs("EventDate2"),1)
Response.Write("</li>")
end if
if len(xrs("Bullet3")) > 0 Then
Response.Write("<li>")
Response.Write xrs("Bullet3")
Response.Write("</li>")
end if
if isdate(xrs("EventDate3")) Then
Response.Write("<li>")
Response.Write FormatDateTime(xrs("EventDate3"),1)
Response.Write("</li>")
end if
if len(xrs("Bullet4")) > 0 Then
Response.Write("<li>")
Response.Write xrs("Bullet4")
Response.Write("</li>")
end if
if isdate(xrs("EventDate4")) Then
Response.Write("<li>")
Response.Write FormatDateTime(xrs("EventDate4"),1)
Response.Write("</li>")
end if
if len(xrs("Bullet5")) > 0 Then
Response.Write("<li>")
Response.Write xrs("Bullet5")
Response.Write("</li>")
end if
if isdate(xrs("EventDate5")) Then
Response.Write("<li>")
Response.Write FormatDateTime(xrs("EventDate5"),1)
Response.Write("</li>")
end if
if len(xrs("Bullet6")) > 0 Then
Response.Write("<li>")
Response.Write xrs("Bullet6")
Response.Write("</li>")
end if
if isdate(xrs("EventDate6")) Then
Response.Write("<li>")
Response.Write FormatDateTime(xrs("EventDate6"),1)
Response.Write("</li>")
end if
if len(xrs("Bullet7")) > 0 Then
Response.Write("<li>")
Response.Write xrs("Bullet7")
Response.Write("</li>")
end if
if isdate(xrs("EventDate7")) Then
Response.Write("<li>")
Response.Write FormatDateTime(xrs("EventDate7"),1)
Response.Write("</li>")
end if
if len(xrs("Bullet8")) > 0 Then
Response.Write("<li>")
Response.Write xrs("Bullet8")
Response.Write("</li>")
end if
if isdate(xrs("EventDate8")) Then
Response.Write("<li>")
Response.Write FormatDateTime(xrs("EventDate8"),1)
Response.Write("</li>")
end if
if len(xrs("Bullet9")) > 0 Then
Response.Write("<li>")
Response.Write xrs("Bullet9")
Response.Write("</li>")
end if
if isdate(xrs("EventDate9")) Then
Response.Write("<li>")
Response.Write FormatDateTime(xrs("EventDate9"),1)
Response.Write("</li>")
end if
xrs.MoveNext
Loop
Response.Write("</ul>")
Response.Write("</td></tr>")
' Close
xrs.Close
Set xrs = Nothing
xConn.Close
Set xConn = Nothing
%>
</table>
//*******************************
I need to know what assemblies to reference and how to declare the
vars(types?) and components used. Any help is appreciated.
Thanks,
B
Re: Help with ASP translation
Author: Robin
Date: Tue, 13 Feb 2007 01:17
Date: Tue, 13 Feb 2007 01:17
35 lines
1793 bytes
1793 bytes
Hey there, As a starting point; Delphi uses := for assigning. = is for comparison only. Delphi uses // for comments (there are other ways too) Delphi uses single quotes instead of double quotes for strings. Delphi uses nil instead of nothing. In some cases, FreeAndNil may be better. (as it frees the memory) Variables would be declared using the key word var, along with their type, separated by a colon. Like this: var xCon : ADODB.Connection; strCon : String; etc..... Creating an object (instanciating it) is done by assigning it a created object. Like this: myVariable := myObjectType.Create; or in your example: xCon := ADODB.Connection.Create; -- Robin. Australian Bridal Accessories := http://www.bridalbuzz.com.au Turbo for Noobs (a work in progress) := http://turbofornoobs.blogspot.com/
Re: Help with ASP translation
Author: Robin
Date: Tue, 13 Feb 2007 01:23
Date: Tue, 13 Feb 2007 01:23
16 lines
1431 bytes
1431 bytes
Benedictum wrote: > I need to know what assemblies to reference and how to declare the > vars(types?) and components used. Any help is appreciated. I almost forgot, you reference assemlies in the references of the project manager, and put them in the 'uses' section of the code. I would suppose you want to reference 'ADODB' -- Robin. Australian Bridal Accessories := http://www.bridalbuzz.com.au Turbo for Noobs (a work in progress) := http://turbofornoobs.blogspot.com/
Re: Help with ASP translation
Author: Benedictum
Date: Tue, 13 Feb 2007 02:18
Date: Tue, 13 Feb 2007 02:18
23 lines
1745 bytes
1745 bytes
Thanks for the reminder. I am quite familiar with Delphi but I have problems translating the VB script syntax. e.g. what does it mean when it says "set xrs=... etc"? Anyway, I will try your suggestions. "Robin" <Robin@.com> wrote in message news:45d112eb$1@newsgroups.borland.com... > Benedictum wrote: >> I need to know what assemblies to reference and how to declare the >> vars(types?) and components used. Any help is appreciated. > > I almost forgot, > > you reference assemlies in the references of the project manager, and put > them in the 'uses' section of the code. > > I would suppose you want to reference 'ADODB' > > -- > Robin. > > Australian Bridal Accessories := http://www.bridalbuzz.com.au > Turbo for Noobs (a work in progress) := http://turbofornoobs.blogspot.com/
Re: Help with ASP translation
Author: Robin
Date: Tue, 13 Feb 2007 02:47
Date: Tue, 13 Feb 2007 02:47
30 lines
1874 bytes
1874 bytes
Benedictum wrote: > Thanks for the reminder. I am quite familiar with Delphi but I have problems > translating the VB script syntax. e.g. what does it mean when it says "set > xrs=... etc"? > Anyway, I will try your suggestions. > Hi Ben' Sorry, I mistook the question. To take another bight at the apple: My VB sucks, but from what I can tell, the 'set' keyword forces an assign as opposed to a comparison. (where Delphi would use = and :=) MyVar = MyObject could be testing for equality, or assigning the value. By putting 'set' in front, you force it to assign a value.... I think....... So in Delphi you would remove the word 'set' as it is unnessesary whith Delphi's explicit ':=' assignment operator. Good luck! -- Robin. Australian Bridal Accessories := http://www.bridalbuzz.com.au Turbo for Noobs (a work in progress) := http://turbofornoobs.blogspot.com/
Re: Help with ASP translation
Author: Benedictum
Date: Tue, 13 Feb 2007 18:42
Date: Tue, 13 Feb 2007 18:42
37 lines
2180 bytes
2180 bytes
Thanks, I will keep that in mind. Let me go back to my dungeon and play around with ASP translation. I'll be back... --B "Robin" <Robin@.com> wrote in message news:45d126b1@newsgroups.borland.com... > Benedictum wrote: >> Thanks for the reminder. I am quite familiar with Delphi but I have >> problems translating the VB script syntax. e.g. what does it mean when it >> says "set xrs=... etc"? >> Anyway, I will try your suggestions. >> > > Hi Ben' > > Sorry, I mistook the question. To take another bight at the apple: > > My VB sucks, but from what I can tell, the 'set' keyword forces an assign > as opposed to a comparison. (where Delphi would use = and :=) > > MyVar = MyObject could be testing for equality, or assigning the value. > > By putting 'set' in front, you force it to assign a value.... > > I think....... > > So in Delphi you would remove the word 'set' as it is unnessesary whith > Delphi's explicit ':=' assignment operator. > > Good luck! > > -- > Robin. > > Australian Bridal Accessories := http://www.bridalbuzz.com.au > Turbo for Noobs (a work in progress) := http://turbofornoobs.blogspot.com/
Re: Help with ASP translation
Author: danny heijl
Date: Tue, 13 Feb 2007 20:02
Date: Tue, 13 Feb 2007 20:02
19 lines
1419 bytes
1419 bytes
Benedictum schreef:
> ... but I have problems
> translating the VB script syntax. e.g. what does it mean when it says
> "set xrs=... etc"?
VBScript uses Set when the left-hand side is an object.
So you can write
i = 1 'i is an integer
but you have to write
Set Con = CreateObject("ADODB.Connection") 'Con is an object
Danny
---
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads