LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default insert data ODBC


Hey thanks on the library thing – that worked

But now I can not get the Execute to work – run-time error’91 object
variable or with block variable not set.

Any suggestions?
Sub insertdata() 'soruceDBkey, DAILY_DATE, CODE, VALUE)
'test cases

Dim ws As Worksheet
Dim DBkey As String
Dim DAILYDATE() As String
Dim CODE() As String
Dim VALUE() As String

Dim sqlStmt As String
'Dim sqlstmtdelete As String
Dim connectionStr As String
Dim wrkODBC As Workspace 'DAO
Dim cnWERP As Connection
Dim rsLIMS As Recordset


Set ws = Sheets("G211_C")
PrefDATEr = Range("F65000").End(xlUp).Row
soruceDATEr = Range("b65000").End(xlUp).Row
count = 0
If soruceDATEr PrefDATEr Then
DBkey = ws.Range("f6")
For Each num In ws.Range("B" & PrefDATEr + 1 & ":B" & soruceDATEr)
count = count + 1
ReDim Preserve DAILYDATE(1 To count)
DAILYDATE(count) = num
Next num
count = 0
For Each num In ws.Range("c" & PrefDATEr + 1 & ":c" & soruceDATEr)
count = count + 1
ReDim Preserve CODE(1 To count)
CODE(count) = num
Next num
count = 0
For Each num In ws.Range("d" & PrefDATEr + 1 & ":d" & soruceDATEr)
count = count + 1
ReDim Preserve VALUE(1 To count)
VALUE(count) = num
Next num

End If

'Setup WERP Database
Set wrkODBC = CreateWorkspace("WERPworkspace", _
"admin", "", dbUseODBC)
'
'open connection object supplied informatio in the connect string
connectionStr = "ODBC;DATABASE=WRED;UID=rpfeilst;PWD=Nowwhat1;DSN= WRED"
';

Set cnWRED = wrkODBC.OpenConnection("DBHYDRO", _
dbDriverNoPrompt, , _
connectionStr)

wrkODBC.BeginTrans

'need testing added here

sqlStmt = "insert into DM_DAILY_DATA(DBKEY, DAILY_DATE, CODE, VALUE)
values ('" & DBkey & "','" _
& DAILYDATE(1) & "','" & CODE(1) & "','" & VALUE(1) &
"')"

cnWERP.Execute sqlStmt
wrkODBC.commitTrans
cnWRED.Close
'End

'ErrHandler:
' wrkODBC.rollback
' cnWRED.Close
'response = MsgBox(errMsg, vbCritical, "Error")
End Sub


*** Sent via Developersdex http://www.developersdex.com ***
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ODBC data insert to Oracle renee New Users to Excel 0 October 18th 05 08:37 PM
ODBC connection for insert into SQL Server nevada Excel Programming 1 February 23rd 04 04:14 PM
Get SQL data to Excel without ODBC Ken Valenti[_2_] Excel Programming 3 January 13th 04 10:50 PM
Importing ODBC Data .. anywhere?? Ignacio Excel Programming 0 September 29th 03 11:07 AM
How to insert data into microsoft excel sheet using ODBC API Siddharth Mehta Excel Programming 0 July 31st 03 06:57 AM


All times are GMT +1. The time now is 12:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"