473,542 Members | 16,813 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple htm vbscript snippet for appending database record

Does anyone have a simple html vbscript or other type of snippet they
can share that appends a record to a access database via ADO or DAO?
I would like to allow users that don't have Microsoft Access a way of
adding records to a access database from a simple web page. I don't
want to have to setup ODBC or anything like that I just want to put
the web page on the network for anyone to access. Most of the users
would use the local access front end but those who don't have Access
would just open up the .htm file and post the information from the web
form. If anyone has the time to cut & paste an example that would be
great.
Nov 13 '05 #1
9 12319
On 23 Nov 2004 11:33:29 -0800, so**********@netzero.net (Pete) wrote:
Does anyone have a simple html vbscript or other type of snippet they
can share that appends a record to a access database via ADO or DAO?
I would like to allow users that don't have Microsoft Access a way of
adding records to a access database from a simple web page. I don't
want to have to setup ODBC or anything like that I just want to put
the web page on the network for anyone to access. Most of the users
would use the local access front end but those who don't have Access
would just open up the .htm file and post the information from the web
form. If anyone has the time to cut & paste an example that would be
great.


Hi
Do you mean local / networked database?
If script is not disabled you can run a simple .vbs file such as

Set conn = WScript.CreateObject("ADODB.Connection")
MdbFilePath = "C:\db1.mdb"
conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" &
MdbFilePath & ";"

SQL = "INSERT INTO Table1 ( colour, path ) SELECT [colour]+1 AS Expr1,
[path] & '1' AS Expr2 FROM Table1;"

conn.Execute(SQL)
conn.Close

Or did you mean a server database, using ASP? Code would be similar,
something like

<%
Set conn = server.CreateObject("ADODB.Connection")

MdbFilePath = Server.MapPath("db1.mdb")
conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" &
MdbFilePath & ";"

SQL = "INSERT INTO Table1 ( colour, path ) SELECT [colour]+1
AS Expr1, [path] & '1' AS Expr2 FROM Table1;"

conn.Execute(SQL)
conn.Close
%>

David
Nov 13 '05 #2
Yes it would be a network backend .mdb database. That's exactly the
syntax I'm looking for but I need to embed this in a simple .html file
with a textbox and button so that users can insert the record to the
mdb via the vbscript. Would you happen to have the syntax to activate
this from a web page? Any method will do (vbscript asp ...) Thanks
Nov 13 '05 #3
On 24 Nov 2004 10:22:19 -0800, so**********@netzero.net (Pete) wrote:
Yes it would be a network backend .mdb database. That's exactly the
syntax I'm looking for but I need to embed this in a simple .html file
with a textbox and button so that users can insert the record to the
mdb via the vbscript. Would you happen to have the syntax to activate
this from a web page? Any method will do (vbscript asp ...) Thanks


Hi
See the example at
http://www.4guysfromrolla.com/webtec...tml#postadlink
which gives generic code for database insert via HTML form and ASP.
David

Nov 13 '05 #4

"Pete" <so**********@netzero.net> wrote in message
news:8f**************************@posting.google.c om...
Yes it would be a network backend .mdb database. That's exactly the
syntax I'm looking for but I need to embed this in a simple .html file
with a textbox and button so that users can insert the record to the
mdb via the vbscript. Would you happen to have the syntax to activate
this from a web page? Any method will do (vbscript asp ...) Thanks

If you need only a single textbox, to get data from the user, then using a
stand-alone vb-script would be the simplest (without using a web page) but
using a web-page would give you more control and if you used something like
asp, then no-one could see/amend the script. However, there are two
hurdles: Firstly, you need to have a machine running IIS, and you should try
to publish an initial test page first. Once you have that working you can
create the script to add the record, but you need to let us know something
about the table structure for the record to be added. For example, database
has a single table tblContacts with two fields, ConID is an autonumber field
which serves as the primary key and ConName is the contact's name which is
input by the user. With that sort of info, someone could write the script.
Nov 13 '05 #5
"Eric Schittlipz" <er**@schittlipz.com> wrote in message news:<co**********@hercules.btinternet.com>...
"Pete" <so**********@netzero.net> wrote in message
news:8f**************************@posting.google.c om...
Yes it would be a network backend .mdb database. That's exactly the
syntax I'm looking for but I need to embed this in a simple .html file
with a textbox and button so that users can insert the record to the
mdb via the vbscript. Would you happen to have the syntax to activate
this from a web page? Any method will do (vbscript asp ...) Thanks

If you need only a single textbox, to get data from the user, then using a
stand-alone vb-script would be the simplest (without using a web page) but
using a web-page would give you more control and if you used something like
asp, then no-one could see/amend the script. However, there are two
hurdles: Firstly, you need to have a machine running IIS, and you should try
to publish an initial test page first. Once you have that working you can
create the script to add the record, but you need to let us know something
about the table structure for the record to be added. For example, database
has a single table tblContacts with two fields, ConID is an autonumber field
which serves as the primary key and ConName is the contact's name which is
input by the user. With that sort of info, someone could write the script.

You could try a simple html application. You would probably want to
add some more robust data validation. It doesn't require a server.
Only IE 5 and above and vbScript.

http://msdn.microsoft.com/workshop/a...taoverview.asp

The example below is very basic but should give you an idea of what it
does.

<html>
<head>
<title>
Data Add Form
</title>
<script language="vbscript">
sub cmdAdd_onClick
dim dbEng
dim wrksp
dim db

if VerifyData()=true then

set dbEng = createobject("dao.dbengine.36")
dbEng.systemdb = "pathtoworkgroupfile"
dbEng.defaultuser = "username"
dbEng.defaultpassword = "password"

set wrksp = dbEng.workspaces(0)

set db = wrksp.opendatabase("PathToDataBase",false,false)

db.execute "INSERT INTO tblData(DataField) " _
& "VALUES('" & txtData.value & "');",128

msgbox "Data Added"

txtData.value = ""

db.close
set db = nothing
wrksp.close
set wrksp = nothing
set dbEng = nothing

else

msgbox "Hey enter Data"
txtData.value=""

end if

end sub

function VerifyData()

if len(trim(txtData.value))=7 then

if isnumeric(txtData.value) then

VerifyData=true

else

VerifyData=false

end if

else

VerifyData=false

end if

end function

</script>
</head>
<body>
<fieldset>
<legend>Enter data to add</legend>
<center>
<input type="text" size="7" maxlength="7" name="txtData"></br>
</p>
<input type="button" name="cmdAdd" value="Add">
</center>
</fieldset>
</br>
</body>
</html>
Nov 13 '05 #6
"Dan Morgan" <us****@yahoo.com> wrote in message
news:fe**************************@posting.google.c om...
"Eric Schittlipz" <er**@schittlipz.com> wrote in message
news:<co**********@hercules.btinternet.com>...
"Pete" <so**********@netzero.net> wrote in message
news:8f**************************@posting.google.c om...
> Yes it would be a network backend .mdb database. That's exactly the
> syntax I'm looking for but I need to embed this in a simple .html file
> with a textbox and button so that users can insert the record to the
> mdb via the vbscript. Would you happen to have the syntax to activate
> this from a web page? Any method will do (vbscript asp ...) Thanks

If you need only a single textbox, to get data from the user, then using
a
stand-alone vb-script would be the simplest (without using a web page)
but
using a web-page would give you more control and if you used something
like
asp, then no-one could see/amend the script. However, there are two
hurdles: Firstly, you need to have a machine running IIS, and you should
try
to publish an initial test page first. Once you have that working you
can
create the script to add the record, but you need to let us know
something
about the table structure for the record to be added. For example,
database
has a single table tblContacts with two fields, ConID is an autonumber
field
which serves as the primary key and ConName is the contact's name which
is
input by the user. With that sort of info, someone could write the
script.

You could try a simple html application. You would probably want to
add some more robust data validation. It doesn't require a server.
Only IE 5 and above and vbScript.

http://msdn.microsoft.com/workshop/a...taoverview.asp

The example below is very basic but should give you an idea of what it
does.

<html>
<head>
<title>
Data Add Form
</title>
<script language="vbscript">
sub cmdAdd_onClick
dim dbEng
dim wrksp
dim db

if VerifyData()=true then

set dbEng = createobject("dao.dbengine.36")
dbEng.systemdb = "pathtoworkgroupfile"
dbEng.defaultuser = "username"
dbEng.defaultpassword = "password"

set wrksp = dbEng.workspaces(0)

set db = wrksp.opendatabase("PathToDataBase",false,false)

db.execute "INSERT INTO tblData(DataField) " _
& "VALUES('" & txtData.value & "');",128

msgbox "Data Added"

txtData.value = ""

db.close
set db = nothing
wrksp.close
set wrksp = nothing
set dbEng = nothing

else

msgbox "Hey enter Data"
txtData.value=""

end if

end sub

function VerifyData()

if len(trim(txtData.value))=7 then

if isnumeric(txtData.value) then

VerifyData=true

else

VerifyData=false

end if

else

VerifyData=false

end if

end function

</script>
</head>
<body>
<fieldset>
<legend>Enter data to add</legend>
<center>
<input type="text" size="7" maxlength="7" name="txtData"></br>
</p>
<input type="button" name="cmdAdd" value="Add">
</center>
</fieldset>
</br>
</body>
</html>


Agreed this has some advantages over a simple vbs file, especially when
there needs to be some form of user interface. I did write a quick one for
someone who needed to do some data manipulation with word tables but didn't
have Access. However, I haven't ever sold an hta application. The idea
never seemed to take off and you don't really see many around.

Nov 13 '05 #7
You answered my question. A statement that I know is unfortunately
true: new records cannot be added from a web page without having IIS
or some other type of web server on the client or server side. Simply
put you can not post any web page on your company's network and expect
it to interact with your database without having administrative access
and IIS. The whole reason behind this is to develop a method for
inserting records without having Access installed on the client's Pc.
I suppose one crude solution is to build a connection from excel since
most client pc have excel installed. The other solution I thought of
is to develop a simple 32bit vb .exe file with a standard input form
and copy that app if they didn't have access installed. If anyone
else has got a easier solution please let me know.
Nov 13 '05 #8

"Pete" <so**********@netzero.net> wrote in message
news:8f**************************@posting.google.c om...
You answered my question. A statement that I know is unfortunately
true: new records cannot be added from a web page without having IIS
or some other type of web server on the client or server side. Simply
put you can not post any web page on your company's network and expect
it to interact with your database without having administrative access
and IIS. The whole reason behind this is to develop a method for
inserting records without having Access installed on the client's Pc.
I suppose one crude solution is to build a connection from excel since
most client pc have excel installed. The other solution I thought of
is to develop a simple 32bit vb .exe file with a standard input form
and copy that app if they didn't have access installed. If anyone
else has got a easier solution please let me know.

IIS would be needed for ASP, but it's not the only possibility if you need
web pages. Did you see Dan's suggestion? Just amend the code slightly with
your own database details, and save this plain text file with a .hta
extension. Otherwise creating an exe file with something like Visual Basic
would be good. Another solution would be to create a runtime installation
using the Developer's version of Access, but that would probably be too much
for a simple application.
Nov 13 '05 #9
Yep. I thought there was something like this out there. After
searching and searching I was ready to give up until I saw the post
from Dan about the HTA solution. Wow this is exactly what I was
looking for. A simple solution that I actually got to work. Now I'll
have to test it when I go back to work Monday. I am pretty confident
that it will work. Thanks for the help!
http://msdn.microsoft.com/workshop/a...taoverview.asp

The example below is very basic but should give you an idea of what it
does.
if VerifyData()=true then

set dbEng = createobject("dao.dbengine.36")
dbEng.systemdb = "pathtoworkgroupfile"
dbEng.defaultuser = "username"
dbEng.defaultpassword = "password"

set wrksp = dbEng.workspaces(0)

set db = wrksp.opendatabase("PathToDataBase",false,false)

Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
4734
by: Samantha Smit | last post by:
Hi, I am trying to create a simple asp page that has one command button that updates a database. The URL of the page is like this: http://MyServer.com/Update.asp?UserName=Tom My asp code is like this: %@ Language=VBScript %> <!--#include file="includes/openconnection.asp"-->
3
14034
by: Asif Rahman | last post by:
Hi all! Please improve on the following code to make sure the record gets deleted only when the function returns false. Now I see the msgbox, but the record gets deleted no matter the user clicks yes or no. Thanks in advance. Asif =======================
1
2207
by: Anna Warloe | last post by:
This might be a dumb question, but I am pretty new to Access.... I am trying to write code in Access to take river forecasts which are delivered as attachments in emails and append the data into an Access Database. Some forecasts are updated 4 times a day and others are only updated daily. I am trying to write a code which will only...
1
1994
by: oasd | last post by:
I'm having difficulty appending data. I have an import macro (using the Transferspreadsheet function) to import data from an excel spreadsheet (located in a USB attached to the pc) to an access database. The data in the USB has addtional info to be added to the respective record in the database. The problem is that the data is not appended to...
3
1900
by: MLH | last post by:
I have a query, qryAppend30DayOld260ies that attempts to append records to tblCorrespondence. When run, it can result in any of the following: appending no records, appending 1 record or appending many records. Two of the target fields in tblCorrespondence receiving values in the append operation are and . For any given VehicleJobID value, I...
27
4585
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res = $doc->loadHTMLFile("./aBasicSearchResult.html"); if ( $res == true ) { $zip = $doc->getElementById('zipRaw_id')->value; if ( 0 != $zip ) {
2
7972
by: JNariss | last post by:
I keep getting the following error message when trying to preview my page: Microsoft VBScript compilation error '800a0400' Expected statement /TESTESC.asp, line 33
0
1538
by: HydroPnik | last post by:
Hi all! What a great community you have here. Being an Access newbie I have already used much information gleaned from the other posters for my current project. I have been tasked with creating a database that will link to a table ("tbl_Data File) located in another database ("Database1"). Changes will be made to a customer record queried from...
1
3349
by: anniefs | last post by:
hi help me i m so much stuck int he code and i have no time .... i used ASP VBscipt and javascript functions with MS database javascript function add records in MS DB by using ASP vbscript recordset varible when user click the save button then some values save in the database so i write javascript function to add the records... here...
0
7567
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7718
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7665
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5239
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4878
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1790
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.