Hi How Can we Import data from database to global sheet by scripting not by right clicking on global sheetThanks

Showing Answers 1 - 9 of 9 Answers

krishnaveni

  • Nov 24th, 2006
 

hi,

try this THIS WORKS FOR FLIGHT RESERVATIONS EXAMPLE, if u have created connection string

Set dbexample = CreateObject("ADODB.Connection")

dbexample.ConnectionString =DSN

dbexample.Open

Set rcRecordSet= dbexample.Execute("SELECT Customer_Name from Orders")

irow = 1

rcRecordset.MoveFirst

Do

' DataTable.SetCurrentRow(irow)

DataTable.Value("UserName",dtLocalsheet) = rcRecordset("Customer_Name")

      irow = irow+1

      rcRecordset.MoveNext

DataTable.SetCurrentRow(irow)

Loop Until rcRecordset.EOF

tf.close

  Was this answer useful?  Yes

asvksastry

  • Nov 20th, 2008
 

Set dbexample=CreateObject ("ADODB.Connection")
dbexample.ConnectionString= DSN Name in quotes eg "Train"
dbexample.open
Set rcRecordSet=dbexample.Execute("select col1,col2,col3 from table_name")
Dim irow
irow=1
rcRecordSet.MoveFirst
Do
    DataTable.SetCurrentRow(irow)
  DataTable.Value("col1", dtGlobalSheet)=rcRecordSet("col1")
  DataTable.Value("col2",dtGlobalSheet)=rcRecordSet("col2")
  DataTable.Value("col3",dtGlobalSheet)=rcRecordSet("col3")
  irow=irow+1
  rcRecordSet.MoveNext
        Loop Until rcRecordset.EOF
dbexample.close

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions