This script was generated by
Import Expert 400. Once you generate a script, you can modify
the script to add additional user actions.
Set ImpObj= CreateObject("SQLT400Import.sqltImport")
ImpObj.ShowImportUI = True
ImpObj.DataSource = 1
'Create Connection String
Dim SourceConStr
SourceConStr = ""
SourceConStr = SourceConStr & "Provider=Microsoft.Jet.OLEDB.4.0;Password='';User ID=Admin;"
SourceConStr = SourceConStr & "Data Source=C:\CODE\VB98\TR.mdb;Mode=Share Deny None;Extended Properties='';"
SourceConStr = SourceConStr & "Jet OLEDB:System database='';Jet OLEDB:Registry Path='';"
SourceConStr = SourceConStr & "Jet OLEDB:Database Password='';Jet OLEDB:Engine Type=5;"
SourceConStr = SourceConStr & "Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;"
SourceConStr = SourceConStr & "Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password='';"
SourceConStr = SourceConStr & "Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;"
SourceConStr = SourceConStr & "Jet OLEDB:Don't Copy Locale on Compact=False;"
SourceConStr = SourceConStr & "Jet OLEDB:Compact Without Replica Repair=False;"
'Open Data Source
ImpObj.SourceConnection.Open SourceConStr
'Set up SQL Statement
Dim SQLStmt
SQLStmt = ""
SQLStmt = SQLSTmt & "SELECT [mkt], "
SQLStmt = SQLStmt & "[id], "
SQLStmt = SQLStmt & "[name], "
SQLStmt = SQLStmt & "[opid], "
SQLStmt = SQLStmt & "[dadd], "
SQLStmt = SQLStmt & "[phone], "
SQLStmt = SQLStmt & "[fax], "
SQLStmt = SQLStmt & "[email], "
SQLStmt = SQLStmt & "[website], "
SQLStmt = SQLStmt & "[addr], "
SQLStmt = SQLStmt & "[city], "
SQLStmt = SQLStmt & "[st], "
SQLStmt = SQLStmt & "[zip] FROM nsadvertisers"
ImpObj.SourceSQL = SQLStmt
'Opening target connection
ImpObj.TargetConnection.Open "DSN=AA;UID=HARNER;PWD=harner;"
ImpObj.vDSN = "AA"
ImpObj.vUID = "HARNER"
ImpObj.vPWD = "harner"
'Setting up the Import!
'Issue Drop to remove any previous version of table.
'you might want to remove this statement if you do not wish to previous instance.
'however, your script will fail if the table already exists.
'Addition of the on error code causes the script not to fail if the table exists.
on error resume next
ImpObj.TargetConnection.Execute "DROP TABLE IMPTEST.p3"
on error goto 0'Create the target table!
Dim vCreateStmt
vCreateStmt = ""
vCreateStmt = vCreateStmt & "CREATE TABLE IMPTEST.p3 ( "
vCreateStmt = vCreateStmt & " mkt VARCHAR(3) , "
vCreateStmt = vCreateStmt & " id INTEGER , "
vCreateStmt = vCreateStmt & " name VARCHAR(50) , "
vCreateStmt = vCreateStmt & " opid VARCHAR(3) , "
vCreateStmt = vCreateStmt & " dadd DATE , "
vCreateStmt = vCreateStmt & " phone VARCHAR(30) , "
vCreateStmt = vCreateStmt & " fax VARCHAR(30) , "
vCreateStmt = vCreateStmt & " email VARCHAR(80) , "
vCreateStmt = vCreateStmt & " website VARCHAR(80) , "
vCreateStmt = vCreateStmt & " addr VARCHAR(250) , "
vCreateStmt = vCreateStmt & " city VARCHAR(50) , "
vCreateStmt = vCreateStmt & " st VARCHAR(2) , "
vCreateStmt = vCreateStmt & " zip VARCHAR(10) )"
ImpObj.TargetConnection.Execute vCreateStmt
'Label on statements to create headings and labels
Dim vLblStmt
vLblStmt = "LABEL ON COLUMN IMPTEST.p3 ( "
vLblStmt = vLblStmt & "mkt TEXT IS 'mkt' , "
vLblStmt = vLblStmt & "id TEXT IS 'id' , "
vLblStmt = vLblStmt & "name TEXT IS 'name' , "
vLblStmt = vLblStmt & "opid TEXT IS 'opid' , "
vLblStmt = vLblStmt & "dadd TEXT IS 'dadd' , "
vLblStmt = vLblStmt & "phone TEXT IS 'phone' , "
vLblStmt = vLblStmt & "fax TEXT IS 'fax' , "
vLblStmt = vLblStmt & "email TEXT IS 'email' , "
vLblStmt = vLblStmt & "website TEXT IS 'website' , "
vLblStmt = vLblStmt & "addr TEXT IS 'addr' , "
vLblStmt = vLblStmt & "city TEXT IS 'city' , "
vLblStmt = vLblStmt & "st TEXT IS 'st' , "
vLblStmt = vLblStmt & "zip TEXT IS 'zip' )"
ImpObj.TargetConnection.Execute vLblStmt
Dim vHdrStmt
vHdrStmt = "LABEL ON COLUMN IMPTEST.p3 ( "
vHdrStmt = vHdrStmt & "mkt IS 'mkt ' , "
vHdrStmt = vHdrStmt & "id IS 'id ' , "
vHdrStmt = vHdrStmt & "name IS 'name ' , "
vHdrStmt = vHdrStmt & "opid IS 'opid ' , "
vHdrStmt = vHdrStmt & "dadd IS 'dadd ' , "
vHdrStmt = vHdrStmt & "phone IS 'phone ' , "
vHdrStmt = vHdrStmt & "fax IS 'fax ' , "
vHdrStmt = vHdrStmt & "email IS 'email ' , "
vHdrStmt = vHdrStmt & "website IS 'website ' , "
vHdrStmt = vHdrStmt & "addr IS 'addr ' , "
vHdrStmt = vHdrStmt & "city IS 'city ' , "
vHdrStmt = vHdrStmt & "st IS 'st ' , "
vHdrStmt = vHdrStmt & "zip IS 'zip ' )"
ImpObj.TargetConnection.Execute vHdrStmt
ImpObj.CreateTarget = False
ImpObj.AddLibrary "IMPTEST"
ImpObj.TargetLibrary = "IMPTEST"
ImpObj.TargetTableName = "p3"
ImpObj.InitializeTargetCols
ImpObj.AddMapByName "mkt", "mkt"
ImpObj.AddMapByName "id", "id"
ImpObj.AddMapByName "name", "name"
ImpObj.AddMapByName "opid", "opid"
ImpObj.AddMapByName "dadd", "dadd"
ImpObj.AddMapByName "phone", "phone"
ImpObj.AddMapByName "fax", "fax"
ImpObj.AddMapByName "email", "email"
ImpObj.AddMapByName "website", "website"
ImpObj.AddMapByName "addr", "addr"
ImpObj.AddMapByName "city", "city"
ImpObj.AddMapByName "st", "st"
ImpObj.AddMapByName "zip", "zip"
ImpObj.GoMapped
MsgBox "Finished"
|