oledb for vfp错误:在Web服务器上运行asp.net时路径或文件名无效

oledb for vfp错误:在Web服务器上运行asp.net时路径或文件名无效,asp.net,database,visual-studio-2012,visual-foxpro,Asp.net,Database,Visual Studio 2012,Visual Foxpro,我使用microsoft oledb for visualfoxpro驱动程序开发web应用程序asp.net连接到visual fox pro数据库自由表(.dbf)。 当我在开发连接时使用vs2013运行程序时,一切正常。 但当我的网站在Web服务器上运行时,它无法搜索或连接到vfp数据库 我得到这个错误:路径或文件名无效 这是我连接vfp数据库的代码 Try 'if use visual fox pro Connect to a single DBF-file

我使用microsoft oledb for visualfoxpro驱动程序开发web应用程序asp.net连接到visual fox pro数据库自由表(.dbf)。 当我在开发连接时使用vs2013运行程序时,一切正常。 但当我的网站在Web服务器上运行时,它无法搜索或连接到vfp数据库 我得到这个错误:路径或文件名无效

这是我连接vfp数据库的代码

Try
            'if use visual fox pro Connect to a single DBF-file
            ConnectionString = "Provider=vfpoledb;Data Source=//database/event/event/OPD/OUT.DBF;sourcetype=DBF;exclusive=No;Collating Sequence=machine; User ID=stat1;Password = stat1;"
            dBaseConnection = New OleDb.OleDbConnection(ConnectionString)
            dBaseConnection.Open()

            sCommand = "SELECT lastdate,save_id,count(*) AS Tcoder FROM OUT.DBF WHERE lastdate BETWEEN CTOD('" & TextBox1.Text & "') and CTOD('" & TextBox2.Text & "') AND typeevent LIKE '%" & TextBox3.Text & "%' "
            sCommand &= "AND lasttime >= '" & ddlFromTime.SelectedValue & "' AND lasttime <= '" & ddlToTime.SelectedValue & "' GROUP BY lastdate,save_id ORDER BY Tcoder DESC "
            dBaseCommand = New OleDb.OleDbCommand(sCommand, dBaseConnection)
            '
            Dim dt As DataTable = GetData(dBaseCommand)
            GridView1.DataSource = dt
            GridView1.DataBind()
            '
            dBaseConnection.Close()
        Catch ex As OleDb.OleDbException
            Response.Write("Error: " + ex.Message)
        End Try
试试看
'如果使用visual fox pro连接到单个DBF文件
ConnectionString=“Provider=vfpoledb;数据源=//database/event/event/OPD/OUT.DBF;sourcetype=DBF;exclusive=No;排序顺序=machine;用户ID=stat1;密码=stat1;”
DBASconnection=新的OleDb.OleDb连接(ConnectionString)
dbasconnection.Open()
sCommand=“选择lastdate,保存\u id,将(*)作为OUT.DBF中的Tcoder,其中lastdate介于CTOD(‘“&TextBox1.Text&“’)和CTOD(‘“&TextBox2.Text&“’)之间,类型为事件,如“%”&TextBox3.Text&“%””

sCommand&=“AND lasttime>=”&ddlFromTime.SelectedValue&“”AND lasttime首先,您的连接字符串应该只指向表所在的路径,而不是.dbf文件的实际名称。然后,您可以从位于连接到路径中的任何.dbf进行查询

第二,在构建查询时,避免SQL注入,因为您现在已经完全打开了,请执行字符串连接。为了防止这种情况,VFP使用“?”作为参数的占位符,并且需要按照查询中显示的相同顺序添加参数

ConnectionString = "Provider=vfpoledb;Data Source=//database/event/event/OPD;sourcetype=DBF;exclusive=No;Collating Sequence=machine; User ID=stat1;Password = stat1;"
dBaseConnection = New OleDb.OleDbConnection(ConnectionString)
dBaseConnection.Open()

' Notice all the "?" place-holders for the parameters.
sCommand = 
  @"SELECT lastdate, save_id, count(*) AS Tcoder    
       FROM OUT.DBF
       WHERE BETWEEN( lastdate, ?, ? )
          AND typeevent LIKE ?
          AND lasttime >= ?
          AND lasttime <= ?
       GROUP BY 
          lastdate,
          save_id 
       ORDER BY 
          Tcoder DESC ";

' get the command instance
dBaseCommand = New OleDb.OleDbCommand(sCommand, dBaseConnection)
' NOW, add the parameters IN ORDER as they appear... starting with the dates

' but you will have to convert the ".Text" values to a date field in VB.net 
' first, then the date-based field will be properly recognized in the VFP call.  Sorry not fluent in VB to convert, but you should be able to get that.
dBaseCommand.Parameters.AddWithValue( "parmFromDate", TextBox1.Text );
dBaseCommand.Parameters.AddWithValue( "parmFromDate", TextBox2.Text );

' now for the "TypeEvent" criteria, no wrapping the text within quotes
' as the query knows it is a string, so don't explicitly add quotes.
dBaseCommand.Parameters.AddWithValue( "parmTypeEvent", "%"+ TextBox3.Text +"%");

' It appears your LASTTIME field are string-based, so no conversion
' just strings like other.
dBaseCommand.Parameters.AddWithValue( "parmTime1", ddlFromTime.SelectedValue );
dBaseCommand.Parameters.AddWithValue( "parmTime2", ddlToTime.SelectedValue );

' Now, finish getting the data and setting the Data source to the result
Dim dt As DataTable = GetData(dBaseCommand)
GridView1.DataSource = dt
GridView1.DataBind()

dBaseConnection.Close()
ConnectionString=“Provider=vfpoledb;数据源=//数据库/event/event/OPD;sourcetype=DBF;独占=否;排序顺序=机器;用户ID=stat1;密码=stat1;"
DBASconnection=新的OleDb.OleDb连接(ConnectionString)
dbasconnection.Open()
请注意参数的所有“?”占位符。
sCommand=
@选择lastdate,将\u id,count(*)另存为Tcoder
FROM OUT.DBF
其中介于(最后日期,,?)
你喜欢什么?
和上次>=?
上次呢