pulling data from ACCESS to html file via vbscript

  • Thread starter Thread starter thread
  • Start date Start date
T

thread

Hi everyone
can someone can give me a code sample of vbscript that presenting
ACCESS database on html without usaghe of DSN
 
Are you looking for an example that uses JET, or ms-access?

You do realize that every copy of windows ships with a copy of JET, and thus
you don't need ms-access, or even to install ms-access to read a ms-access
(mdb) file on a windows box.

So, are you looking for a ms-access example, or a JET example?
 
can you give me example of both?
i want to enter deep into this issue and i want to explore both options

Albert D. Kallal ëúá:
 
thread said:
can you give me example of both?
i want to enter deep into this issue and i want to explore both options

Well, if you have ms-access, then you can build a report, and export that
report as HTML. This would save large amounts of coding. On the other hand
if this is to be a web based acppion, ms-acceess is NOT thread safe, and I
would recommand this.

However, if you have ms-access, then you can use any of the ojbects and
systems that ms-access has.

However, this means that ms-access will be loaded to achfive your goals, and
it is fiarly heavey program to load.

Rmember, it is the JET datbase enigne that ships with windows that ms-acces
uses, and htus you DO NOT need ms-access. I would ONLY use ms-access if you
intend to use speiclfy features (such as exmproting a table as a formatted
html report).

a windows script that runs code in side of ms-access looks like:

dim accessApp

msgbox "Click ok to run batch job",64

set accessApp = createObject("Access.Application")

accessApp.OpenCurrentDataBase("C:\Documents and Settings\Albert\My
Documents\Access\ScriptExample\MultiSelect.mdb")

accessApp.Run "TimeUpDate"

accessApp.Quit

set accessApp = nothing

msgbox "Job complete", 64

The above would load (use ms-access as a com object) ms-access, and run
some code inside of a standard code module in ms-access.

Of course, to read data, you could go:

dim accessApp
dim rst
dim strSql

msgbox "Click ok to run batch job",64

set accessApp = createObject("Access.Application")

accessApp.OpenCurrentDataBase("C:\Documents and Settings\Lawrence\My
Documents\Access\ScriptExample\MultiSelect.mdb")

strSql = "select * from contacts"

set rst = accessApp.Currentdb.OpenRecordSet(strSql)

do while rst.eof = false
msgbox rst("FirstName")
rst.movenext
loop
rst.close

I see little, if any advantage of writing scripts to automate ms-access, as
you can run and design/build code inside of ms-access anyway.

However, as mentioned, it is JET THAT reads mdb files, and that ships with
every copy of windows...so, really, no need to use ms-access, but simply use
the windows dao library. Here is a code snip:

Set dbeng = CreateObject("DAO.DBEngine.36")
strMdbFile = "C:\Documents and Settings\Albert\My
Documents\Access\ScriptExample\MultiSelect.mdb"
Set db = dbeng.OpenDatabase(strMdbFile)
strQuery = "select * from contacts"
Set rs = db.OpenRecordset(strQuery)
rs.movefirst
If rs.EOF = true Then
quit
End If

strTextOut = "C:\t5.txt"
set fs = Wscript.CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(strTextOut, 2, True)
' 2 = write, 1 = read

do while rs.EOF = false
strOutText = rs("LastName")
ts.Writeline strOutText
rs.movenext
loop
ts.close
rs.close

In the above I used the familiar fileSystemObject that everyone who writes
windows scripts is familiar with. This outputs the data to a standard text
file...
The above examples can be pasted into notepad, and if you rename the
extensions as .vbs, they will run on your windows box without you having
ms-access (well, the 2nd examples anyway).
 
ms-acceess is NOT thread safe, and I
would recommand this.

should read:

ms-acceess is NOT thread safe, and I
would NOT recommand this.
 
i would like to make it as html file is the same code?
Albert D. Kallal ëúá:
 
sorry i didnt mentain this but i would like to use it as a web
application,can it be possible as well,can you sample me with relevant
code for this?

Albert D. Kallal ëúá:
 
The script code to open a oracle database, or ms-access, or mysql, or ms-sql
server is going to depend on your web tools.

So, you have to go to your vendor (or correct newsgroup).

Ms-access has absolute NOTHING to do with web based applications.

So, you are in the wrong place, wrong tools, and wrong approach....
what would you recommend to use?

Albert D. Kallal ëúá:
would recommand this.

should read:

ms-acceess is NOT thread safe, and I
would NOT recommand this.

You do not want to use word, or excel, or ms-access as a automaton object on
a web server, because you can have mutilate instances (more then one user)
accessing the web site. it is not stable, and is a obvious problem to anyone
who is familiar with computers. (That problem is that ms-access (or word) is
designed for the desktop, and being interacted with a SINGLE user and a
mouse. Ms-access is not designed to be "run/automated" by a web site. It is
just complete the wrong approach. access is a single user desktop interface
application, not something for a web site. Access is part of office, just
like word, or excel...these are NOT web tools.

Common sense would dictate that then you use the DAO example to read data,
since as above mentioned, ms-access is not a web product, nor are you going
have a great stable product if you choose to automation ms-access. So, you
would use the examples that read via DAO. And, take heart, those examples,
are just that...examples, and are vbscript. I don't know what development
tools and platform you are using (it is only you later responses that you
revealed that you not using ms-access at all, you don't need ms-access, and
you now revealed that you are building a web based system).

So, to read/use data in a web based system, you are MUCH better off to use
ADO in place of DAO (you can ask about this difference in a appropriate
newsgroup that is relevant to YOUR CHOICE of development tools that you are
currently use for the web system).

So, for web stuff, you LIKELY will use ADO. ADO is a data better data object
then DAO for web stuff. ADO allows you SAME CODE to work with oracle, or
JET, or sql server. (the code is not so tightly tied to the database engine
as compared to DAO).

I don't know what tools, and development platform you are using, but *most*
code to read data is going to be the same if you use ADO. (this once again
simple means that you need to ask the question in your appropriate
newsgroup..as the code will be the SAME for JET, or sql server or whatever
data engine you choose).
..
So, check in your approach newsgroup for the given tools you are using (but,
you certainly don't need, nor are using ms-access anymore here).

You *can* use the JET database engine for light weight web sites (and, as
mentioned, you don't need ms-access). However, with so many free database
engines (including several from Microsoft), there is little, if any
advantage to using JET for a web site these days (so, once again, wrong
tools...wrong newsgroup)....

You also don't mention what development tools and languages you chosen to
build the web site. My examples were vbscript, and were answered originated
to a windows user, not a web site developer. Those examples as such don't
need a web server, or even web services to run.

You would be best to choose a scripting language you are familiar with, and
ALSO ONE THAT is supported by the web tools you plan to use.

If you not made that choice, then you have a wide open choice. (the asp.net
tools would be a good starting place). So, pick your web development tools,
and then go from there....questions such as reading a mdb (or oracle, or
mysql, or ms-sql server) are much minor in the scope of things, and the code
to read that data and preoduce HTML is going to be the same.

good luck..
 
yeah.. and every copy of Office includes a copy of SQL Server called
'MSDE'

MDB is dead spit on people that use it.. I've seen source in 'SQL
Server 7 Secrets' that will allow you to make a simple extended stored
procedure call in order to 'get html into a database'


you copy the DLL, register it in Windows and then register the extended
stored procedure in SQL.. it's not rocket science



-Tom
 
I fully agree.. using Access on a server anywhere is laughable

use a simple extended stored procedure from 'SQL Server 7 Secrets' book

xp_getHtml I think that it's called

MDB shouldn't be used on a webserver for any reason; because one of the
greatest benefits of webpages are that they available for 24x7
operation.

using a wimpy database like MS Access MDB format kindof defeats this
purpose

-Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top