Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Vbscript to microsoft access connection

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,63145
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Vbscript to microsoft access connection
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Vbscript to microsoft access connection - 8/5/2008 5:18:18 AM   
  serioussam13x

 

Posts: 4
Score: 0
Joined: 8/5/2008
Status: offline
Hello,

I have been searching and performing trial and error for the last three hours. I am trying to use a simple Vbscript form to connect to a access database for the purpose of adding, updating, and deleting records. Unfortunately I have been unsuccesful. I have taken bits and pieces from examples found on the internet to create a working guideline that I can work off of. Here is what I have.

<html>
<Script Language="VBScript">
Sub DBAdd
dim a
dim b
dim c
dim d
dim e
dim f

a = document.DBAddForm.account.value
b = document.DBAddForm.url.value
c = document.DBAddForm.category.value
d = document.DBAddForm.leadsource.value
e = document.DBAddForm.notes.value
f = document.write(Date)
Dim objConnection
Dim objRecordSet
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Open _
"Provider = Microsoft.Jet.OLEDB.4.0; " & _
"Data Source = H:\queue13x.mdb"

dim ar as ADODB.recordset
set ar=new adodb.recordset
ar.open {select * from queue13xtbl}
ar.execute "INSERT INTO queue13xtbl(account,url,category,leadsource,notes) VALUES ('"& a &"','"& b &"','"& c &"','"& d &"','"& e &"','"& f &"')"


End Sub
</script>
</head>
<body>
<h3>Me</h3>

<FORM NAME="DBAddForm" OnSubmit="DBAdd()">
<table cellspacing=0 cellpadding=5 border=0>
<tr><td>Enter Account Number:</td><td><INPUT TYPE="TEXT" NAME="account"></td></tr>
<tr><td>Enter URL:</td><td><INPUT TYPE="TEXT" NAME="url"></td></tr>
<tr><td>Enter Category:</td><td><INPUT TYPE="TEXT" NAME="category"></td></tr>
<tr><td>Enter Lead Source:</td><td><INPUT TYPE="TEXT" NAME="leadsource"></td></tr>
<tr><td>Enter Notes:</td><td><textarea name ="notes" rows=8 cols=30></textarea></td></tr>
<tr><td><br></td><td><input TYPE="Submit" VALUE="Submit"></td></tr>
</table>
</FORM>
</html>



 
 
Post #: 1
 
 RE: Vbscript to microsoft access connection - 8/5/2008 7:09:38 AM   
  ehvbs

 

Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi serioussam13x,

the most blatant errors:

objConnection.Open _
"Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=H:\queue13x.mdb"
(no spaces)

set ar=new adodb.recordset 
(that's VBA, not VBScript; you'll have to use CreateObject)

ar.open {select * from queue13xtbl}
(VBScript string literals are delimited by ")

ar.execute "INSERT INTO queue13xtbl(account,url,category,leadsource,notes) VALUES ('"& a &"','"& b &"','"& c &"','"& d &"','"& e &"','"& f &"')"
(.Execute is a method of ADODB.Connection, not ADODB.Recordset)

In your shoes, I'd start with a simple command line script (cscript) to read and display a recordset;
then move on to updates, insertions, and deletions.

Good luck!

ehvbs

(in reply to serioussam13x)
 
 
Post #: 2
 
 RE: Vbscript to microsoft access connection - 8/5/2008 7:25:58 AM   
  serioussam13x

 

Posts: 4
Score: 0
Joined: 8/5/2008
Status: offline
I will work on this throughout the week. Thank you for taking the time to look at this and evaluate my program. Much appreciated.

(in reply to ehvbs)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Vbscript to microsoft access connection Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts