LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to insert data into MS Access defined by data type

Hi all,

I've managed to insert data (from cluster of strings) into MS Access database.. I would like to know how to define the data type as all of the elements in the cluster that I created are in String data type.. So when it writes the data into database, all will be in Text data type. What I want is, before it writes to database, the elements (string) should be converted to my own preference data type (like data/time, integer etc)...

Hope someone would help...THANKS
0 Kudos
Message 1 of 13
(3,162 Views)
Hi 222,

From what I know Microsoft Access cannot accept data directly from DDE clients.
To get data into an Access database you must create a macro in that database to import the data from a file. In the simple case these macros need only be two actions long.  First do a SetWarnings to supress Access dialogs, then do a TransferSpreadsheet or TransferText to get the data. After this macro is defined, you can call the macro by sending an execute to that database with the macro name as the data.
I also think that for this to work Access must be running with the database open.

Hope this help 😉


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 13
(3,162 Views)
Hi Titou,

Errm... I don't quite understand and I'm sure I can't do it... sigh.... Anyway, thanks.....

Kindly look into the jpg file, I just want to know how to get those strings from the cluster to be converted into respective data type and then insert it into MS Access database...

If I direct insert the cluster into the database, all data type in MS Access will be in Text data type....

Anyone expert in database connectivity pls help.... THANKS!!!
0 Kudos
Message 3 of 13
(3,157 Views)

Hi

You can wire a cluster of different datatypes directly to write them to the database. You only have to define the database correctly, so that the corresponding columns are of the specific type you want to save.

In the attached picture you can see an extract of a vi I use to write data into an access database.

Thomas

 

Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 4 of 13
(3,152 Views)
Hi Becktho

I set my data type in database as Date/Time... Then I wire the date (in String format) into the database... It gives me error saying that Type Mismatch. What should I do?
0 Kudos
Message 5 of 13
(3,147 Views)
Wire a date and not a string...
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 6 of 13
(3,144 Views)
But if I wire the time stamp, in the MS Access it writes as 'Long Binary Data' and the data type is 'OLE Object'....  From the jpg file that you gave, you also wired string into the bundle....Smiley Tongue
0 Kudos
Message 7 of 13
(3,141 Views)
Yes I saw it after giving you answer... shame on me..  Smiley Sad
 
But did you format the string correctly? Maybe this causes the problem.
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 8 of 13
(3,137 Views)
Yup, I've tried converting it to date format but in Access it came out Text data type...
0 Kudos
Message 9 of 13
(3,133 Views)
So could you post your vi? Without code it's always difficult to locate an error...
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 10 of 13
(3,131 Views)