Page 1 of 1

MS-Access without plugin...

PostPosted: Wed Dec 10, 2008 1:05 pm
by David de Argentina
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

Re: MS-Access without plugin...

PostPosted: Thu Dec 11, 2008 9:55 am
by dpayer
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.

PostPosted: Thu Dec 11, 2008 11:26 am
by David de Argentina
Hi DavidP

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

Cheers,
David de Argentina

PostPosted: Thu Dec 11, 2008 11:52 am
by Neosoft Support
The Microsoft Database Access Control (MDAC) is included as part of Windows.