1

Konu: OleDB Hatası Hk.

Öncelikle herkese merhaba..

Aşağıdaki kodu önceden bilgisayarımda çalıştırdığımda sorun yoktu ( yada ben öyle hatırlıyorum - başka PC de de sorunsuz çalışıyorda olabilir )

Şimdi ise şu hatayı alıyorum :
"OLE IDispatch exception code 0 from Microsoft OLE DB Service Components: Başlatma dizesi biçimi OLE DB belirtimine uymuyor..."

Sorunu nasıl düzeltebilirim.

Visual Fox Pro
*!*    Author: Cetin Basoz

*!* Program Name: creating fixed columns in grids
 
#Define TESTDATALOC "C:\Program Files\Microsoft Visual FoxPro 9\Samples\Data\Tasdrade.DBC"
 
oForm = createobject('myForm')
oForm.Show
Read events
 
Define CLASS myform AS form
  Top = 0
  Left = 0
  Height = 450
  Width = 250
  DoCreate = .T.
  Caption = "Form1"
  Name = "Form1"
 
  Add OBJECT hflex AS olecontrol WITH ;
    Top = 0, ;
    Left = 0, ;
    Height = 420, ;
    Width = 250, ;
    Name = "Hflex", ;
    OleClass = 'MSHierarchicalFlexGridLib.MSHFlexGrid'
 
  Procedure Init
  Local oRecordset,oConnection, strCn, strShp
*!* Conventional SQL joins
  strCn =    [Provider=MSDASQL.1;Persist Security Info=False;]+;
    [Extended Properties=]+;
    ["DSN=Visual FoxPro Database;UID=;]+;
    [SourceDB=TESTDATALOC;SourceType=DBC;]+;
    [Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;"
]
  strShp =    [select customer.cust_id, Company, orders.order_id, ]+;
    [ order_date, orditems.product_id  from customer ]+ ;
    [ inner join orders ]+;
    [ on customer.cust_id = orders.cust_id ]+;
    [  inner join orditems ]+;
    [ on orditems.order_id = orders.order_id ]
*!* Conventional SQL joins
 
  oRecordset = CreateObject("adodb.recordset")
  oConnection = CreateObject("adodb.connection")
 
  With oConnection
    .Provider = "MSDataShape"
    .ConnectionString = strCn
    .Open
  Endwith
  With oRecordset
    .ActiveConnection = oConnection
    .Source = strShp
    .Open
  Endwith
  With this.hflex
    .Datasource = oRecordset
    .FixedCols = 2 && Fixed columns on left  < -----------------------
    .ColWidth(0,0) = 0 && Hide unused column 0 leaving only cust_id fixed
    For ix = 1 to .Cols - 1
      .MergeCol(ix) = .t.  && Merge cols
    Endfor
    .Mergecells = 3
  Endwith
Endproc
  Procedure QueryUnLoad
  Clear events
Endproc
Enddefine

Yorumlar ve yardımlar için şimdiden teşekkürler.

Uğur
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır.  Türk Atasözü

2

Re: OleDB Hatası Hk.

Visual Fox Pro
#Define TESTDATALOC "C:\Program Files\Microsoft Visual FoxPro 9\Samples\Data\Tasdrade.DBC"

satirini

Visual Fox Pro
#Define TESTDATALOC "C:\Program Files\Microsoft Visual FoxPro 9\Samples\Tastrade\Data\Tastrade.DBC"

olarak dene

3

Re: OleDB Hatası Hk.

Soykan abi;

Değişen bir şey olmadı smile

Kime çatiyim sence smile

Not: Kod sende normal çalıştı mı?

Uğur
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır.  Türk Atasözü

4

Re: OleDB Hatası Hk.

asagidaki linkler konu gecmis , senin ornek kodunda DSN ile dataya baglanilmaya calisiyor tanimli olmadigi icin calismaz.

http://www.fox4um.com/topic/855/nasil-b … pabilirim/
http://www.fox4um.com/topic/517/grid-ic … -kullnimi/
http://www.fox4um.com/topic/414/hierarc … datashape/

5

Re: OleDB Hatası Hk.

Tabii ki kodun sahibine kizmalisin, ne oyle ODBC driver kullanmis hem de DSN ile, sanki VFP9'da destekleniyor gibi:)

Ornek cok sen iste yeter ki:)

Visual Fox Pro
TESTDATALOC = _samples+"data\testdata.DBC"

 
PUBLIC oForm
oForm = createobject('myForm')
oForm.Show
 
Define CLASS myform AS form
  Top = 0
  Left = 0
  Height = 450
  Width = 750
  DoCreate = .T.
  Caption = "Form1"
  Name = "Form1"
 
  Add OBJECT hflex AS olecontrol WITH ;
    Top = 0, ;
    Left = 0, ;
    Height = 420, ;
    Width = 750, ;
    Name = "Hflex", ;
    OleClass = 'MSHierarchicalFlexGridLib.MSHFlexGrid'
 
  Procedure Init
    Local oRecordset,oConnection, strCn, strShp
 
    strCn =    [Provider=MSDataShape;Persist Security Info=False;]+;
      [Data Source=]+TESTDATALOC+[;Data Provider=VFPOLEDB]
 
*!*        strShp = [SHAPE TABLE customer ]+;
*!*          [  APPEND ( (SHAPE TABLE orders   ]+;
*!*          [    APPEND (TABLE orditems RELATE order_id TO order_id)) ]+;
*!*          [  RELATE cust_id TO cust_id ) ]
 
    strShp = [SHAPE {select Company,Cust_id from customer} as Customers ]+;
      [  APPEND ( {select cust_id,order_date,order_id from orders} RELATE cust_id TO cust_id ) ]
 
    oRecordset = CreateObject("adodb.recordset")
    oConnection = CreateObject("adodb.connection")
 
    With oConnection
      .Provider = "MSDataShape"
      .ConnectionString = strCn
      .Open
    Endwith
 
    With oRecordset
      .ActiveConnection = oConnection
      .Source = strShp
      .Open
    Endwith
 
    With this.hflex
      .Datasource = oRecordset
      .GridColorBand(0) = rgb(255,0,0)
      .GridColorBand(1) = rgb(0,0,255)
      .Cols(0) = 2
      .ColWidth(0,0) = 16*15
      .ColWidth(1,0) = 250*15
      .CollapseAll
      *.BandDisplay = 1
    Endwith
  Endproc
Enddefine

Bunda kolonlari tasi (ama farkedilecek sekilde tasi mesela "Employee"'i en basa):

Visual Fox Pro
LOCAL oCon as AdoDb.Connection, oRS as ADODb.Recordset

oCon = CREATEOBJECT('AdoDb.Connection')
oCon.ConnectionString = ;
  "Provider=VFPOLEDB;Data Source="+_samples+'data\testdata.dbc'
oCon.Open()
 
TEXT to m.lcSQL NOSHOW PRETEXT 8
Select c.cust_id, c.company,
  o.order_id, o.order_date,
  e.First_Name-(' '+e.Last_Name) As Employee,
  oi.line_no, p.prod_name,
  oi.unit_price, oi.quantity
  FROM  testdata!customer c
  INNER Join testdata!orders o
  ON  c.cust_id = o.cust_id
  INNER Join testdata!Employee e
  ON  o.emp_id = e.emp_id
  INNER Join testdata!orditems oi
  ON  o.order_id = oi.order_id
  INNER Join testdata!products p
  ON  oi.product_id = p.product_id
  order By p.prod_name
ENDTEXT
 
oRS = oCon.Execute(m.lcSQL)
PUBLIC oForm
oForm = CREATEOBJECT('myForm',oRS)
oForm.Show()
 
 
DEFINE CLASS myForm as Form
  Height = 450
  Width = 750
  Add OBJECT hflex AS olecontrol WITH ;
    Height = 420, ;
    Width = 750, ;
    DragIcon = "c:\program files\microsoft visual foxpro 9\graphics\cursors\h_point.cur",;
    OleClass = 'MSHierarchicalFlexGridLib.MSHFlexGrid'
 
  PROCEDURE init(toRS)
    with This.HFlex
      .Datasource = toRS
      for ix = 1 to .Cols - 1
        .MergeCol(ix) = .t.
      endfor
      .MergeCells = 3
    endwith
    this.DoSort(This.HFlex)
  ENDPROC
 
  PROCEDURE doSort(toObject)
    with toObject
      .Col = 0
      .ColSel = .Cols - 1
      .Sort = 1 && Generic Ascending
    endwith
  ENDPROC
 
  PROCEDURE hFlex.MouseDown
    LPARAMETERS button, shift, x, y
    with this
      .Tag = ""
      If .MouseRow = 0
        .Tag = Str(.MouseCol)
        .Drag( 1 )
      endif
    endwith
  ENDPROC
 
  PROCEDURE HFlex.DragDrop
    LPARAMETERS oSource, nXCoord, nYCoord
    If !empty(this.Tag)
      with this
        .Redraw = .F.
        .ColPosition(Val(.Tag)) = .MouseCol
        thisform.DoSort(this)
        .Redraw = .t.
      endwith
    endif
  endproc
enddefine

6 Son düzenleyen, ugurlu2001 (14.01.2010 18:32:39)

Re: OleDB Hatası Hk.

Üstat, sana kızılırmı...

Ancak senden fırça yenir. Malum sen ne kadar uyarsan da benzer ( yada aynı hataları ). yapıp duruyoruz. ( kendi adıma söyledim )

Şimdi nerden çıktı diyceksin. Aradığım cevap aslında arşivden çıktı :

http://www.fox4um.com/topic/1290/gridde-kisir-dongu/

Sorunumda tam olarak; Grid 'e ait sorguyu tekrar çalıştırıp Cursor 'u yeniden oluşturduğumda meydana çıkıyordu. Sorun Griddeki colon WIDTH lerinin bozulmasıydı. Grid.Rowsource = " " yapınca düzeldi ...

Ellerine sağlık smile

Uğur
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır.  Türk Atasözü