none
Feature is not available. RRS feed

  • Question

  • I have to introduce some. When I switched from XP to Vista I found to my distress that my major DBs written in VFP where 95% of my life is located has become unusable. It worked just fine in XP but Vista wants to have nothing to do with Fox. I tried many things to no avail. I've decided to rewrite the code in C# and use only the DB tables as storage.  The advantage of using XBase tables vs Sql Server tables is tremendous speed of execution of data retreaval and search, even nonidexed. I am almost 50% through in this task but I got in trouble when I tried to execute a Stored Procedure.

     

    This SP (not shwon here) is a modified version of VFP code which worked exceptionally well in XP. I could not use it unmolested because stupidly in VFP I passed object related to the major Form (treeView, etc) in this procedure which was not a stored procedure but a part of a .prg file.

     

    What feature is not available? I tried various parameters in ExecuteReader including null--the same error.

     

    More explanations: this SP (in Fox) is visible in my server explorer in VS2005 in the left pane. I can open it up. It is located in the proper place in VFP DB.

     

    public string searchForWords (string cALias, string wordToFind)
        {

          string outStr = "";
          using (OleDbConnection conn = new OleDbConnection ( @"Provider=VFPOLEDB.1;Data Source=C:\VFP_Projects\DATA\ComeAndGetDatBase\comeandget.dbc" ))
          {
            conn.Open ( );
            OleDbCommand cmdm = new OleDbCommand ( );
            cmdm.Connection = conn;
            cmdm.CommandType = CommandType.StoredProcedure;
            cmdm.CommandText = "doSearchForCSharp";
            cmdm.Parameters.Add ( "cAlies", OleDbType.VarChar, 6 ).Value = cALias;
            cmdm.Parameters.Add ( "patternToFind", OleDbType.VarChar, 13 ).Value = wordToFind;
            OleDbDataReader rdr = cmdm.ExecuteReader ( CommandBehavior.Default  );  // <== error message here.
            outStr = (string)rdr.GetValue ( 0 );
          }
          return outStr;
          // doSearchFoCSharp (cAlias,patternToFind)
        }


    System.Data.OleDb.OleDbException was unhandled
      Message="Feature is not available."
      Source="Microsoft OLE DB Provider for Visual FoxPro"
      ErrorCode=-2147467259
      StackTrace:
           at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
           at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
           at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
           at System.Data.OleDb.OleDbCommand.ExecuteReader()
           at ComeAndGet.FillTables.searchForWords(String cALias, String wordToFind) in C:\VCsharp_Projects\ComeAndGet\ComeAndGet\FillTables.cs:line 29
           at ComeAndGet.Form1.pushFIND_Click(Object sender, EventArgs e) in C:\VCsharp_Projects\ComeAndGet\ComeAndGet\Form1.cs:line 288
           at System.Windows.Forms.Control.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ButtonBase.WndProc(Message& m)
           at System.Windows.Forms.Button.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.Run(Form mainForm)
           at ComeAndGet.Program.Main() in C:\VCsharp_Projects\ComeAndGet\ComeAndGet\Program.cs:line 17
           at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()

    Thanks.
    Wednesday, October 3, 2007 8:48 PM

Answers

  •  boban.s wrote:

    Problem is with combination of ExecuteReader and Fox OleDb provider. I believe that this provider doesn't support ExecuteReader, and maybe DataAdapter will do the job. Reason for that is because DataReader use a cursor on 'server' side to return row by row on the client side, and probably this is not available.

     

    Thanks, four star general. It appears you are right, there is no support for either ExecuteReader or ExecuteNonQuery for stored procedures. I mean it appears OleDb doea not want to have anything to do with SPs.

     

    I actually resolved the problem without it, quite effectively, I think. All t I needed was a full text search. I do not know if there will be any loss in execution time with doing this in C# vs VFP SP but this is what worked for me. It looks I have no other option:

     

    public string searchForWords( string cALias, string wordToFind )

    {

    string outStr = "";

    using (OleDbConnection conn = new OleDbConnection ( @"Provider=VFPOLEDB.1;Data Source=C:\VFP_Projects\DATA\ComeAndGetDatBase\comeandget.dbc" ))

    {

    conn.Open ( );

    OleDbCommand cmdm = new OleDbCommand ( );

    cmdm.Connection = conn;

    cmdm.CommandType = CommandType.Text;

    cmdm.CommandText = "SELECT * FROM CATEGORIES WHERE '" + wordToFind + "' $ named";

    OleDbDataReader rdr = cmdm.ExecuteReader ( );

    if (rdr.HasRows)

    {

    foreach (System.Data.Common.DbDataRecord row in rdr)

    {

    Console.WriteLine ( row[ 0 ] );

    }

    }

    }

    return outStr;

    }

    Thursday, October 4, 2007 4:14 PM

All replies

  • Did u install service pack

    Thursday, October 4, 2007 8:36 AM
  •  vinoth kumar.R wrote:

    Did u install service pack

     

    A service pack for what? VS or Vista? Be specific next time. To forestall your next question, I have installed ALL SPs.

    Thursday, October 4, 2007 2:02 PM
  • I changed the code and got exactly the same error: feature is not available

     

    public string searchForWords (string cALias, string wordToFind)

    {

    string outStr = "";

    using (OleDbConnection conn = new OleDbConnection ( @"Provider=VFPOLEDB.1;Data Source=C:\VFP_Projects\DATA\ComeAndGetDatBase\comeandget.dbc" ))

    {

    conn.Open ( );

    OleDbCommand cmdm = new OleDbCommand ( );

    cmdm.Connection = conn;

    cmdm.CommandType = CommandType.StoredProcedure;

    cmdm.CommandText = "doSearchFoCSharp";

    cmdm.Parameters.Add ( "cAlies", OleDbType.VarChar, 25 ).Value = cALias;

    cmdm.Parameters.Add ( "patternToFind", OleDbType.VarChar, 100 ).Value = wordToFind;

    cmdm.ExecuteNonQuery ( );

    }

    return outStr;

    }

     

    Which feature is not available?

    Thursday, October 4, 2007 3:01 PM
  • Problem is with combination of ExecuteReader and Fox OleDb provider. I believe that this provider doesn't support ExecuteReader, and maybe DataAdapter will do the job. Reason for that is because DataReader use a cursor on 'server' side to return row by row on the client side, and probably this is not available.

    Thursday, October 4, 2007 3:04 PM
  • Shot in the dark here, but is it possible that the version of DAO that comes with Vista is differnt from what you had on XP ? If I understand it correctly ( and I could be dead wrong here ) DAO is responsible for OleDB connections.

     

    Thursday, October 4, 2007 3:34 PM
  •  boban.s wrote:

    Problem is with combination of ExecuteReader and Fox OleDb provider. I believe that this provider doesn't support ExecuteReader, and maybe DataAdapter will do the job. Reason for that is because DataReader use a cursor on 'server' side to return row by row on the client side, and probably this is not available.

     

    Thanks, four star general. It appears you are right, there is no support for either ExecuteReader or ExecuteNonQuery for stored procedures. I mean it appears OleDb doea not want to have anything to do with SPs.

     

    I actually resolved the problem without it, quite effectively, I think. All t I needed was a full text search. I do not know if there will be any loss in execution time with doing this in C# vs VFP SP but this is what worked for me. It looks I have no other option:

     

    public string searchForWords( string cALias, string wordToFind )

    {

    string outStr = "";

    using (OleDbConnection conn = new OleDbConnection ( @"Provider=VFPOLEDB.1;Data Source=C:\VFP_Projects\DATA\ComeAndGetDatBase\comeandget.dbc" ))

    {

    conn.Open ( );

    OleDbCommand cmdm = new OleDbCommand ( );

    cmdm.Connection = conn;

    cmdm.CommandType = CommandType.Text;

    cmdm.CommandText = "SELECT * FROM CATEGORIES WHERE '" + wordToFind + "' $ named";

    OleDbDataReader rdr = cmdm.ExecuteReader ( );

    if (rdr.HasRows)

    {

    foreach (System.Data.Common.DbDataRecord row in rdr)

    {

    Console.WriteLine ( row[ 0 ] );

    }

    }

    }

    return outStr;

    }

    Thursday, October 4, 2007 4:14 PM
  • Alex,

    VFPOLEDB SPs support ExecuteScalar,ExecuteNonQuery,ExecuteReader,ExecuteQuery. You already asked this on VFP forum. Search for my messages on all forums I participate and you'd find one my code samples doing exactly what you want.

    Thursday, October 4, 2007 9:56 PM
  • Alex,

    Here is a sample for you.

     

    Code Block

    using System;
    using System.Data;
    using System.Data.OleDb;

    class sample
    {
    static void Main()
    {
    string strCon = "Provider=VFPOLEDB;"+
    @"Data Source=C:\PROGRAM FILES\MICROSOFT VISUAL FOXPRO 9\SAMPLES\Northwind\northwind.dbc;";
    OleDbConnection con = new OleDbConnection(strCon);
    OleDbCommand cmd = new OleDbCommand();
    cmd.Connection = con;
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "CustOrderHist";
    cmd.Parameters.AddWithValue("p1",OleDbType.Char).Value = "BONAP";
    con.Open();
    OleDbDataReader rdr = cmd.ExecuteReader();
    while (rdr.Read())
    {
     Console.WriteLine("Product Name:{0}, Total Quantity:{1}",
         rdr["ProductName"],
         rdr["Total"]);
    }
    rdr.Close();
    con.Close();
    }
    }

     

     

     

    CustOrderHist stored procedure exists in sample database but anyway here it is if you don't have:

     

    Code Block

    *------------------------------------------------

    PROCEDURE CustOrderHist(tcCustomerID as String )

    *------------------------------------------------

    LOCAL lcCustomerID as String

    lcCustomerID = IIF(VARTYPE(tcCustomerID)!="C","",tcCustomerID)

    SELECT ProductName, SUM(Quantity) AS Total ;

     FROM Products P, OrderDetails OD, Orders O, Customers C ;

     WHERE C.CustomerID = lcCustomerID ;

      AND C.CustomerID = O.CustomerID ;

      AND O.OrderID = OD.OrderID ;

      AND OD.ProductID = P.ProductID ;

     GROUP BY ProductName ;

     INTO CURSOR CustOrderHist

    SETRESULTSET('CustOrderHist')

    RETURN RECCOUNT('CustOrderHist')

    ENDPROC

     

    Also for an ASP.Net version sample check:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=533788&SiteID=1

     

    Thursday, October 4, 2007 11:03 PM
  • Hi Centinbasoz,

     I've got an similar problem with Alex, but my problem appeared when I call ExcecuteNonQuery, I don't know exactly "Feature is not available" means, and how can I resolve this problem. Here is my code :

     string strCon = "Provider=VFPOLEDB;" +
                        @"Data Source=C:\PROGRAM FILES\MICROSOFT VISUAL FOXPRO 9\SAMPLES\Northwind\;";
                OleDbConnection con = new OleDbConnection(strCon);
                OleDbCommand cmd = new OleDbCommand();
                cmd.Connection = con;
                cmd.CommandText = @"create database database_test";

                con.Open();
             
                cmd.ExecuteNonQuery();    
                con.Close();

    Thank you.
    Monday, December 10, 2007 4:06 AM
  • Go to VFP Help==>Index and type in Ole Db. Choose the page:

     

    Unsupported Visual FoxPro Commands and Functions in OLE DB Provider

     

    In the section "C" it lists command "CREATE DTABASE"

     

    It means this feature is not supported by OleDb driver.

    Monday, December 10, 2007 2:09 PM
  • I've got it. But I also saw the Create View command in the unsupported command list, and I can create view by using this command !!?! I'm using foxpro 9 SP2.

    Thanks for you help, Alex.
    Tuesday, December 11, 2007 3:38 AM
  •  Van Dan wrote:
    I've got it. But I also saw the Create View command in the unsupported command list, and I can create view by using this command !!?! I'm using foxpro 9 SP2.

    Thanks for you help, Alex.

     

    You mean you can create a view remotely? Not when you are operating in VFP9? I thought you were reaching VFP DBE via OleDb driver? I can actually believe that you can do what they clain is inaccessible from OleDb. It may be true for a couple of objects/operations/commands but as a rule that list is sort of solid.

     

    You cannot expect that OleDb or ODBC driver will perform the magnitude of operations that are available directly in VFP Studio. It is a big undertaking to write a driver. Some commands are used once in a century, I would guess. MS created the driver with the most sparing implementation. It is actually a very good thing. It makes it faster and more efficient.

    Tuesday, December 11, 2007 10:25 PM