I'm just adding a few points to clarify Ian's excellent example - 

A. Ian's example uses the Oracle provider. For Access you need:

PROVIDER=Microsoft.Jet.OLEDB.4.0

B. Access has problems with some field names unless you enclose them in
square braces. 
Also be careful about delimiters around the data 

e.g. 

INSERT INTO [MyTableName] ([AString],[A Number],[ADate]) VALUES ('Some
Value',SomeNumber,#Some Date#)

C. You can do the whole thing in VBScript including reading the import file.

However this is a little non-obvious - you need to instantiate a
Scripting.FileSystemObject along the lines of:

set fso = CreateObject("scripting.filesystemobject")
Set F = FSO.OpenTextFile(fn, 1)
Do while not F.AtEndOfStream
  s = F.ReadLine 
  MyFields = split(s,MyDelimiter)
  ' do some processing here
Loop

F.Close

I'll let you work out the rest yourself!


Brian Leach

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Ian McGowan
> Sent: 05 March 2004 06:56
> To: 'U2 Users Discussion List'
> Subject: RE: VB primer help ?
> 
> -----Original Message-----
> >From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Maybe one of 
> you has a 
> >trivial example of updating a row in a VB macro?  All the examples I 
> >can find are doing it using a macro EXTERNAL to the 
> database, when the 
> >one I'm using is run from inside the project... did that make sense?
> 
> is there any reason you can't use ODBC or OLEDB and just 
> issue an update statement?  that would seem the most direct 
> route.  this link has an example of the connection string to 
> use for access:
> 
> http://www.asp101.com/tips/index.asp?id=98
> 
> and here's a vbscript example that inserts a bunch of rows.
> you would want to loop over your flat file reading a line at 
> a time, issuing updates like:
> 
> sql = "update mytable set fieldx = '" & valuex & "' where"
> sql = sql & " primarykey = '" & mykey & "'"
> con.execute(sql)
> 
> --------------------------------------------------------------------
> UID = "system1"
> PWD = "*******"
> Service = "marin"
> 
> Set oAux = CreateObject("Sys1Aux.CAux")
> Set Con = CreateObject("ADODB.Connection") Set rs = 
> CreateObject("ADODB.RecordSet") Con.Open( 
> "PROVIDER=MSDAORA;DATA SOURCE=" & Service & ";USER ID=" & UID 
> & ";PASSWORD=" & PWD)
> 
> for i = 1 to 10000
>       sql="insert into trin_temp values ('" & i & "','" & 
> GUIDGen(oAux) & "')"
>       wscript.echo sql
>       con.execute (sql)
> next
> 
> Function GUIDGen(Aux)
>       Dim sGUID
>       sGuid = Aux.GuidGen
>       ' Get rid of the cute curly stuff
>       sGUID = Mid(sGUID, 2, Len(sGUID) - 2)
>       GUIDGen = sGUID
> End Function
> --------------------------------------------------------------
> ---------
> --
> u2-users mailing list
> [EMAIL PROTECTED]
> http://www.oliver.com/mailman/listinfo/u2-users
> 
> ______________________________________________________________
> __________
> This email was checked by MessageLabs SkyScan before entering 
> Microgen.


________________________________________________________________________
This email was checked on leaving Microgen for viruses, similar
malicious code and inappropriate content by MessageLabs SkyScan.

DISCLAIMER

This email and any attachments are confidential and may also be
privileged.

If you are not the named recipient, please notify the sender
immediately and do not disclose the contents to any other
person, use it for any purpose, or store or copy the information.

In the event of any technical difficulty with this email, please
contact the sender or [EMAIL PROTECTED]

Microgen Information Management Solutions
http://www.microgen.co.uk
-- 
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users

Reply via email to