larksp

help with .MDB file Code

3 posts in this topic

#1 ·  Posted (edited)

so i finally got some code to work 
what im looking to do grab some data out of 1 box the code below does it..   With out using string format can it be change to only return the Numbers if it needs to be done with string replace or any of them thats fine just wondered how to go about it

 

ConsoleWrite( _FindVer(@ScriptDir & '\test1.mdb', 'Version') & @CRLF& @CRLF)


Func _FindVer($dbname, $tblname)
    $query = "SELECT * FROM " & $tblname
    $DBCon = ObjCreate("ADODB.Connection")
    $DBCon.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $dbname)
    $DBobj = ObjCreate("ADODB.Recordset")
    $DBobj.CursorType = 1
    $DBobj.LockType = 3
    $DBobj.Open($query, $DBCon)
    $Dbdata = $DBobj.Fields("Version").value ;Retrieve value by field name
;~  $DBdata = $DBobj.Fields(2).value         ;Retrieve value by column number
    $DBCon.Close
;~  MsgBox(0, "testing", $Dbdata)
    Return $Dbdata
EndFunc   ;==>_FindVer

 

Edited by larksp

Share this post


Link to post
Share on other sites



#2 ·  Posted

Can you post a sample of what "$Dbdata" looks like?

What would you prefer it to look like when you are done?

Skysnake


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites

#3 ·  Posted

Table Name Version
Version
wktv1401

Letters are random but far as i know always 4 as in "wktv"

i used $D = StringRegExpReplace($Dbdata, '\D', '') 
return $D
what gives me 1401.. what works fine just wondered was that the best way

could have used stringtrimleft($Dbdata,4) but who knows if it stays 4 letters :) or not   1401 is year 14 month 01

 

also when using objcreate or wmi.. You get $var.'Name' .description or in this case .fields or .value
what is that called so if i wanted to google ObjCreate("ADODB.Connection" to find all of the .WhatEvers i can use
i dont need them but dont know what they are called or referred to by name

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now