Wrox Home  
Search P2P Archive for: Go

  Return to Index  

activex_data_objects thread: Generating scripts on run time !!!


Message #1 by Manish Kumar Sinha <msinha@q...> on Mon, 17 Dec 2001 15:10:27 +0530

Hello,



if someone can tell me how to generate Scripts on runtime for any type of

SQL statement ?



regard

Manish



Message #2 by Mike Wheaton <WheatonM@k...> on Mon, 17 Dec 2001 10:04:05 -0500
How's this?



<%



Dim ConnectionString

ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" &_

 

"DBQ=C:\InetPub\wwwroot\KCMSWEB\kcmss\adotest\nwind.mdb;DefaultDir=;UID=;PWD

=;"



Dim Connection

Set Connection = Server.CreateObject("ADODB.Connection")



Connection.ConnectionTimeout = 30

Connection.CommandTimeout = 80

Connection.Open ConnectionString



' Create a RecordSet Object

Dim rs

set rs = Server.CreateObject("ADODB.RecordSet")



' Retrieve the records

rs.Open "SELECT * FROM Employees", Connection, adOpenForwardOnly,

adLockOptimistic



' This will list all Column headings in the table

Dim item

For each item in rs.Fields

	Response.Write item.Name & "<br>"

next

			

' This will list each field in each record

while not rs.EOF

		

	For each item in rs.Fields

		Response.Write item.Value & "<br>"

	next

		

	rs.MoveNext

wend

	

rs.Close

set rs = nothing



Connection.Close

Set Connection = nothing



%>





























































-----Original Message-----

From: Manish Kumar Sinha [mailto:msinha@q...]

Sent: Monday, December 17, 2001 1:40 AM

To: ActiveX_Data_Objects

Subject: [activex_data_objects] Generating scripts on run time !!!







Hello,



if someone can tell me how to generate Scripts on runtime for any type of

SQL statement ?



regard

Manish








$subst('Email.Unsub').

---

Incoming mail is certified Virus Free.

Checked by AVG anti-virus system (http://www.grisoft.com).

Version: 6.0.281 / Virus Database: 149 - Release Date: 9/18/2001



---

Outgoing mail is certified Virus Free.

Checked by AVG anti-virus system (http://www.grisoft.com).

Version: 6.0.281 / Virus Database: 149 - Release Date: 9/18/2001



Message #3 by Kyle Burns <kburns@c...> on Mon, 17 Dec 2001 10:16:34 -0500
You're going to be much better off displaying this in a table.  I use a

generic function to display recordsets in tabular format:







Function GetHTMLTable(rs)

	Dim sHTML

	sHTML = "<table><tr>"

	Dim fld

	For Each fld In rs.Fields

		sHTML = sHTML & "<th>" & fld.Name & "</th>"

	Next 'fld

	sHTML = sHTML & "</tr>"



	Dim sColumnData



	'retrieve the actual data into a string

	sColumnData = "<tr><td>" & rs.GetString(2, , "</td><td>",

"</td></tr><tr>", "&nbsp;")



	'chop off trailing <tr>

	sColumnData = Left(sColumnData, Len(sColumnData) - 4) & "</table>"



	GetHTMLTable = sHTML & sColumnData

End Function







=================================

Kyle M. Burns, MCSD, MCT

ECommerce Technology Manager

Centra Credit Union

kburns@c...



 



>> -----Original Message-----

>> From: Mike Wheaton [mailto:WheatonM@k...]

>> Sent: Monday, December 17, 2001 10:04 AM

>> To: ActiveX_Data_Objects

>> Subject: [activex_data_objects] RE: Generating scripts on 

>> run time !!!

>> 

>> 

>> How's this?

>> 

>> <%

>> 

>> Dim ConnectionString

>> ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" &_

>>  

>> "DBQ=C:\InetPub\wwwroot\KCMSWEB\kcmss\adotest\nwind.mdb;Defau

>> ltDir=;UID=;PWD

>> =;"

>> 

>> Dim Connection

>> Set Connection = Server.CreateObject("ADODB.Connection")

>> 

>> Connection.ConnectionTimeout = 30

>> Connection.CommandTimeout = 80

>> Connection.Open ConnectionString

>> 

>> ' Create a RecordSet Object

>> Dim rs

>> set rs = Server.CreateObject("ADODB.RecordSet")

>> 

>> ' Retrieve the records

>> rs.Open "SELECT * FROM Employees", Connection, adOpenForwardOnly,

>> adLockOptimistic

>> 

>> ' This will list all Column headings in the table

>> Dim item

>> For each item in rs.Fields

>> 	Response.Write item.Name & "<br>"

>> next

>> 			

>> ' This will list each field in each record

>> while not rs.EOF

>> 		

>> 	For each item in rs.Fields

>> 		Response.Write item.Value & "<br>"

>> 	next

>> 		

>> 	rs.MoveNext

>> wend

>> 	

>> rs.Close

>> set rs = nothing

>> 

>> Connection.Close

>> Set Connection = nothing

>> 

>> %>

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> 

>> -----Original Message-----

>> From: Manish Kumar Sinha [mailto:msinha@q...]

>> Sent: Monday, December 17, 2001 1:40 AM

>> To: ActiveX_Data_Objects

>> Subject: [activex_data_objects] Generating scripts on run time !!!

>> 

>> 

>> 

>> Hello,

>> 

>> if someone can tell me how to generate Scripts on runtime 

>> for any type of

>> SQL statement ?

>> 

>> regard

>> Manish

>> 

>> 




>> $subst('Email.Unsub').

>> ---

>> Incoming mail is certified Virus Free.

>> Checked by AVG anti-virus system (http://www.grisoft.com).

>> Version: 6.0.281 / Virus Database: 149 - Release Date: 9/18/2001

>> 

>> ---

>> Outgoing mail is certified Virus Free.

>> Checked by AVG anti-virus system (http://www.grisoft.com).

>> Version: 6.0.281 / Virus Database: 149 - Release Date: 9/18/2001

>> 

>> 




>> $subst('Email.Unsub').

>> 


  Return to Index