Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem in executing query


Hi,
I want to connect to a Oracle database located on remote machine and
execute the insert query from the macro but i am getting error related
to session object. I am sending the code, please help me out..

CODE
Dim oconn As ADODB.Connection
Set oconn = New Connection
Dim cmd As ADODB.Command
Set cmd = New Command

oconn.ConnectionString = "Driver={Oracle ODBC Driver};" & _
"Dbq=alf;" & _
"Uid=system;" & _
"Pwd=manager1"

cmd.ActiveConnection = oconn
cmd.CommandText = "insert into zzz_ashish values('YYY','22')"
cmd.Execute


--
ashishprem
------------------------------------------------------------------------
ashishprem's Profile: http://www.excelforum.com/member.php...o&userid=31485
View this thread: http://www.excelforum.com/showthread...hreadid=545793

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Problem in executing query

http://www.oracle.com/technology/doc...help/start.htm

--
Regards,
Tom Ogilvy


"ashishprem" wrote:


Hi,
I want to connect to a Oracle database located on remote machine and
execute the insert query from the macro but i am getting error related
to session object. I am sending the code, please help me out..

CODE
Dim oconn As ADODB.Connection
Set oconn = New Connection
Dim cmd As ADODB.Command
Set cmd = New Command

oconn.ConnectionString = "Driver={Oracle ODBC Driver};" & _
"Dbq=alf;" & _
"Uid=system;" & _
"Pwd=manager1"

cmd.ActiveConnection = oconn
cmd.CommandText = "insert into zzz_ashish values('YYY','22')"
cmd.Execute


--
ashishprem
------------------------------------------------------------------------
ashishprem's Profile: http://www.excelforum.com/member.php...o&userid=31485
View this thread: http://www.excelforum.com/showthread...hreadid=545793


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem in executing query


Hi,
I have found a code to connect to Oracle using macro. Dint understan
much in the code but its working fine.
Code :-

Public objSession As Object
Public objDataBase As Object
Dim strSQL As String

Sub final()
ConnectToOracle Worksheets("sheet2")
End Sub

Sub ConnectToOracle(ws1 As Worksheet)
'Create a reference to the OO4O dll
Set objSession = CreateObject("OracleInProcServer.XOraSession")
'Create a reference to my database

Set objDataBase = objSession.OpenDatabase("AshishDB"
"username/password", 0&)

For i = 2 To ws1.UsedRange.Rows.Count
strSQL = "insert into zzz_ashish values('" + ws1.Cells(i, 1) + "','"
CStr(ws1.Cells(i, 2)) + "')"
objDataBase.ExecuteSQL (strSQL)
Next i
End Sub

Regards,
Ashis

--
ashishpre
-----------------------------------------------------------------------
ashishprem's Profile: http://www.excelforum.com/member.php...fo&userid=3148
View this thread: http://www.excelforum.com/showthread.php?threadid=54579

Reply
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
QUERY & HELP: so slow executing VBA code... :S John Keith Excel Worksheet Functions 3 February 13th 06 03:47 PM
QUERY & HELP: so slow executing VBA code... :S John Keith[_2_] Excel Programming 3 February 13th 06 03:47 PM
Problem with MS Query - can't edit query jarems Excel Discussion (Misc queries) 2 December 12th 05 09:42 AM
Problem executing a macro from different workbook where it is Sergio Calleja Excel Discussion (Misc queries) 1 January 17th 05 12:38 PM
Problem with .Background Query option of ODBC Query Shilps Excel Programming 0 April 19th 04 06:41 AM


All times are GMT +1. The time now is 01:57 PM.

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

About Us

"It's about Microsoft Excel"