Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Avi Avi is offline
external usenet poster
 
Posts: 29
Default issue with ODBC connection to DB2

Thanks for the reply Jim !

strQueryText is defined as String and I am getting it from the
Spreadsheet cell.

query i am trying to execute is simple - "Select Item from XYZ.ITEM
where dept = 200 "

Here is the complete procedure.
-----------------------------------------------------------------------------
Private Sub CreateQuery(inQueryIdx As Integer)
'
Dim strQueryName As String, strQueryText As String
Dim strServer, strDatabase, strUid, strPwd As String
Dim xSheet As Worksheet

strQueryName = [querylist].Cells(inQueryIdx, 1)
strQueryText = [querylist].Cells(inQueryIdx, 2)

If strQueryName = "" Or strQueryText = "" Then
Exit Sub
End If

strServer = [querylist].Cells(inQueryIdx, 3)
strDatabase = [querylist].Cells(inQueryIdx, 4)
strUid = [querylist].Cells(inQueryIdx, 5)
strPwd = [querylist].Cells(inQueryIdx, 6)

FindActivateSheet (strQueryName)
Cells.Select
Selection.Delete Shift:=xlUp
Range("A1").Select

With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;Driver={IBM DB2 ODBC
DRIVER};Hostname=udb_db2t.xxx.com;Port=2001;DB=DB2 T;Uid=xxx;Pwd=xxx;"
_
, Destination:=Range("A1"))
.CommandText = strQueryText
.Name = strQueryName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.EnableRefresh = True
.EnableEditing = False
.Refresh BackgroundQuery:=False
End With

Set xSheet = ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)
'xSheet.Columns(9).WrapText = True
Set xSheet = Nothing

End Sub
-----------------------------------------------------------------



On Aug 2, 11:36 am, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
What is the value of strQueryText
in the line
.CommandText = strQueryText
--
HTH...

Jim Thomlinson

"Avi" wrote:
Hi,


I am connecting to DB2 from Excel using IBM OBDC driver. I am able to
connect and getting the data but.. there is a window that pops up
asking me to select the database.. is there a way to get rid of it


here is my code.
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;Driver={IBM DB2 ODBC
DRIVER};Hostname=udb_db2t.xxxxx;Port=2001;DB=DB2T; Uid=xxx;Pwd=xxxxx;"
_
, Destination:=Range("A1"))
.CommandText = strQueryText
.Name = strQueryName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.EnableRefresh = True
.EnableEditing = False
.Refresh BackgroundQuery:=False --- this row pops the
window...
End With


I also see the error message in the window "SQL1013N The database
alias name or database name "" could not be found. SQLSTATE=42705"


looks like i am not defining the database properly..


Can someone please help ..


Thanks
Avinash



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default issue with ODBC connection to DB2

Driver={IBM DB2 ODBC
DRIVER};Database=myDataBase;Hostname=myServerAddre ss;Port=1234;Protocol=TCPIP;Uid=myUsername;Pwd=myP assword;

is the format I found on the WEB. You don't have a Database=myDatabase
clause in yours.

That would be consistent with the error you are getting I would think.

--
Regards,
Tom Ogilvy


"Avi" wrote:

Thanks for the reply Jim !

strQueryText is defined as String and I am getting it from the
Spreadsheet cell.

query i am trying to execute is simple - "Select Item from XYZ.ITEM
where dept = 200 "

Here is the complete procedure.
-----------------------------------------------------------------------------
Private Sub CreateQuery(inQueryIdx As Integer)
'
Dim strQueryName As String, strQueryText As String
Dim strServer, strDatabase, strUid, strPwd As String
Dim xSheet As Worksheet

strQueryName = [querylist].Cells(inQueryIdx, 1)
strQueryText = [querylist].Cells(inQueryIdx, 2)

If strQueryName = "" Or strQueryText = "" Then
Exit Sub
End If

strServer = [querylist].Cells(inQueryIdx, 3)
strDatabase = [querylist].Cells(inQueryIdx, 4)
strUid = [querylist].Cells(inQueryIdx, 5)
strPwd = [querylist].Cells(inQueryIdx, 6)

FindActivateSheet (strQueryName)
Cells.Select
Selection.Delete Shift:=xlUp
Range("A1").Select

With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;Driver={IBM DB2 ODBC
DRIVER};Hostname=udb_db2t.xxx.com;Port=2001;DB=DB2 T;Uid=xxx;Pwd=xxx;"
_
, Destination:=Range("A1"))
.CommandText = strQueryText
.Name = strQueryName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.EnableRefresh = True
.EnableEditing = False
.Refresh BackgroundQuery:=False
End With

Set xSheet = ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)
'xSheet.Columns(9).WrapText = True
Set xSheet = Nothing

End Sub
-----------------------------------------------------------------



On Aug 2, 11:36 am, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
What is the value of strQueryText
in the line
.CommandText = strQueryText
--
HTH...

Jim Thomlinson

"Avi" wrote:
Hi,


I am connecting to DB2 from Excel using IBM OBDC driver. I am able to
connect and getting the data but.. there is a window that pops up
asking me to select the database.. is there a way to get rid of it


here is my code.
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;Driver={IBM DB2 ODBC
DRIVER};Hostname=udb_db2t.xxxxx;Port=2001;DB=DB2T; Uid=xxx;Pwd=xxxxx;"
_
, Destination:=Range("A1"))
.CommandText = strQueryText
.Name = strQueryName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.EnableRefresh = True
.EnableEditing = False
.Refresh BackgroundQuery:=False --- this row pops the
window...
End With


I also see the error message in the window "SQL1013N The database
alias name or database name "" could not be found. SQLSTATE=42705"


looks like i am not defining the database properly..


Can someone please help ..


Thanks
Avinash




  #3   Report Post  
Posted to microsoft.public.excel.programming
Avi Avi is offline
external usenet poster
 
Posts: 29
Default issue with ODBC connection to DB2

Hi Tim.

I had used the database parameter before, but was still getting the
popup. How ever you were able to point out what I was missing.
it was Protocol=TCPIP.. my issue was resolved once i added the
Protocol in the connect string.

Thanks for your help,
Avinash

On Aug 2, 2:02 pm, Tom Ogilvy
wrote:
Driver={IBM DB2 ODBC
DRIVER};Database=myDataBase;Hostname=myServerAddre ss;Port=1234;Protocol=TCPIP;Uid=myUsername;Pwd=myP assword;

is the format I found on the WEB. You don't have a Database=myDatabase
clause in yours.

That would be consistent with the error you are getting I would think.

--
Regards,
Tom Ogilvy

"Avi" wrote:
Thanks for the reply Jim !


strQueryText is defined as String and I am getting it from the
Spreadsheet cell.


query i am trying to execute is simple - "Select Item from XYZ.ITEM
where dept = 200 "


Here is the complete procedure.
-----------------------------------------------------------------------------
Private Sub CreateQuery(inQueryIdx As Integer)
'
Dim strQueryName As String, strQueryText As String
Dim strServer, strDatabase, strUid, strPwd As String
Dim xSheet As Worksheet


strQueryName = [querylist].Cells(inQueryIdx, 1)
strQueryText = [querylist].Cells(inQueryIdx, 2)


If strQueryName = "" Or strQueryText = "" Then
Exit Sub
End If


strServer = [querylist].Cells(inQueryIdx, 3)
strDatabase = [querylist].Cells(inQueryIdx, 4)
strUid = [querylist].Cells(inQueryIdx, 5)
strPwd = [querylist].Cells(inQueryIdx, 6)


FindActivateSheet (strQueryName)
Cells.Select
Selection.Delete Shift:=xlUp
Range("A1").Select


With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;Driver={IBM DB2 ODBC
DRIVER};Hostname=udb_db2t.xxx.com;Port=2001;DB=DB2 T;Uid=xxx;Pwd=xxx;"
_
, Destination:=Range("A1"))
.CommandText = strQueryText
.Name = strQueryName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.EnableRefresh = True
.EnableEditing = False
.Refresh BackgroundQuery:=False
End With


Set xSheet = ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)
'xSheet.Columns(9).WrapText = True
Set xSheet = Nothing


End Sub
-----------------------------------------------------------------


On Aug 2, 11:36 am, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
What is the value of strQueryText
in the line
.CommandText = strQueryText
--
HTH...


Jim Thomlinson


"Avi" wrote:
Hi,


I am connecting to DB2 from Excel using IBM OBDC driver. I am able to
connect and getting the data but.. there is a window that pops up
asking me to select the database.. is there a way to get rid of it


here is my code.
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;Driver={IBM DB2 ODBC
DRIVER};Hostname=udb_db2t.xxxxx;Port=2001;DB=DB2T; Uid=xxx;Pwd=xxxxx;"
_
, Destination:=Range("A1"))
.CommandText = strQueryText
.Name = strQueryName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.EnableRefresh = True
.EnableEditing = False
.Refresh BackgroundQuery:=False --- this row pops the
window...
End With


I also see the error message in the window "SQL1013N The database
alias name or database name "" could not be found. SQLSTATE=42705"


looks like i am not defining the database properly..


Can someone please help ..


Thanks
Avinash



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
ODBC connection failed. Jim Moberg Excel Discussion (Misc queries) 0 October 9th 06 03:48 PM
ODBC Connection Kezzemil Excel Programming 0 October 6th 06 09:15 AM
ODBC connection question matelot Excel Programming 1 September 23rd 06 08:46 PM
ODBC Connection Adrian T[_4_] Excel Programming 4 January 25th 05 08:55 PM
ODBC connection by udl Dorothy[_4_] Excel Programming 1 January 8th 04 05:32 PM


All times are GMT +1. The time now is 05:38 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"