Source language: Translate to:

MS-Access without plugin...

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

MS-Access without plugin...

Postby David de Argentina » Wed Dec 10, 2008 1:05 pm

Hi all,

If you need use MS-Access and you are not interested in use any plugin, this function is exactly for you.

Copy and paste this function on your NeoBook\functions\VBScript folder:

Code: Select all
{NeoBook Function}
Version=5,60
Language=VBScript
Param=[%vbmdb]|Text|Database
Param=[%vbsql]|Text|SQL Instruction
{End}

Dim Conexion, RS, i, out, reccount, Fields, Field, Fcount, textout, FName, FValue, eof, db, sqlstring

db = "[%vbmdb]"
sqlstring = "[%vbsql]"
textout = ""
out = ""

Set Conexion = CreateObject("ADODB.Connection")
Conexion.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & db & ";User Id=admin;Password=;"

Set RS = CreateObject("ADODB.RecordSet")
RS.Open sqlstring, Conexion

set Fields = RS.Fields

'get the Field Count
fcount = Fields.count
publication.nbSetVar "[FCount]", Fcount

'Get the Field Names, you could skip this...

for i = 0 to fcount - 1
 set field = Fields.Item(i)
 Fname = field.name
 if i = 0 then
  Textout = FName
 else
  Textout = Textout &";"& FName
 end if
next
Textout = Textout & "|"

' Now, we work with the recordset
' I use the " ; " character as field delimitator and " | " character as record delimitator, you could change this...

RS.MoveFirst

do

 eof = RS.EOF

 'get the EOF status, you could skip this...
 'publication.nbSetVar "[Feof]", eof

 if eof then exit do
 
 for i = 0 to fcount - 1
  set field = Fields.Item(i)
  Fvalue = field.value
  if i = 0 then
   out = FValue
  else
   out = out &";"& Fvalue
  end if
 next
 Textout = Textout & out & "|"
 RS.MoveNext
loop
 
publication.nbSetVar "[Rset]", Textout

RS.Close
Set RS = Nothing
Conexion.Close
Set Conexion = Nothing



My devaluated cent,
David de Argentina
User avatar
David de Argentina
 
Posts: 1559
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Re: MS-Access without plugin...

Postby dpayer » Thu Dec 11, 2008 9:55 am

David de Argentina wrote:Hi all,

If you need use MS-Access and you are not interested in use any plugin, this function is exactly for you.

Copy and paste this function on your NeoBook\functions\VBScript folder:

~~~~~ lots of nice code here ~~~~~

My devaluated cent,
David de Argentina


David,

I would think you need to have some version of MDAC installed on your machine for this to work. Do you know if this is true?

David P.
User avatar
dpayer
 
Posts: 1382
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Postby David de Argentina » Thu Dec 11, 2008 11:26 am

Hi DavidP

Yes, you need have installed Jet motor (usually comes with MDAC package or Office-Access Package)

Cheers,
David de Argentina
User avatar
David de Argentina
 
Posts: 1559
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Postby Neosoft Support » Thu Dec 11, 2008 11:52 am

The Microsoft Database Access Control (MDAC) is included as part of Windows.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5602
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA


Return to NeoBook Functions - VBScript & JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest