e股脑电脑教程网
  • 首 页
  • 操作系统
  • 应用软件
  • 下载工具
  • 影音视频
  • 办公软件
  • 媒体制作
  • 网站建设
  • 平面设计
  • 数据库
  • 程序开发
  • 视频教程
编辑推荐: | 文章搜索:
您现在的位置: e股脑 >> 数据库 >> FoxPro教程 >> 在ASP.NET中使用Visual FoxPro7.0 >> 教程正文
 
教程搜索
 
 
相关教程
  • 二级FoxBASE上机考试技巧
  • VFP中状态栏控件的使用说明
  • Visual FoxPro 9.0更强大了
  • VFP智能感应的二次开发
  • VFP中多条件数据查询程序的实现
  • VFP应用程序多媒体徽标的实现
  • VFP 6.0网络编程应注意的问题
  • VFP程序的五点经验
  • Visual Foxpro通用报表打印程序
  • 在ASP.NET中使用Visual FoxPro7.0
  • 修复DBF数据表文件的简单方法
  • 在VisualFoxPro5.0中激活InternetExpl
  • 在VFP中制做异型窗口
  • Visual FoxPro 9 集成开发环境新特性
  • Visual FoxPro 9.0 的报表设计器
  • Visual FoxPro 9中新的数据处理方式
 
 

图文教程


  • Windows抢了谁的饭碗 非主流操作系统To

  • 地球还是火星 平常心看“非主流”

  • 综合运用Office 2007批量制作奖状

  • 没有系统盘如何才能修复受损系统?

  • 巧妙运用Excel中边界的附加功能!
 
 
赞 助 商
 
 
在ASP.NET中使用Visual FoxPro7.0
  • 来源:e股脑
  • 点击次数:
  • 更新时间:2007-8-9
}

// 此方法是由 Visual Studio .NET 生成的。

private void Page_Init(object sender, EventArgs e)

{

//

// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。

//

InitializeComponent();

}

// 这段代码是由 Visual Studio .NET 生成的。

#region Web 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要使用

/// 代码编辑器修改此方法的内容。

///

private void InitializeComponent()

{

this.calDate.SelectionChanged += new

System.EventHandler(this.Page_Load);

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

}

}

示例 4:从 ASP.NET Web Service 访问 Visual FoxPro 数据

您可以创建访问 Visual FoxPro 7.0 数据的 ASP.NET Web service。Web service 定义了 CustomersInCountry() 方法,该方法在传递包含国家/地区名称的字符串时,使用 OLE DB 提供程序连接到 Visual FoxPro 7.0 数据库。然后,执行查询以检索指定国家/地区的客户的详细信息。如果返回数据,则将结果集打包为 XML 并返回给调用对象。

XML Web services 没有用户界面,因此本示例也没有 ASPx 文件。下面列出了使用 C# 编写的实现代码。


// 设置对类库的引用。类似于 Visual FoxPro 7.0 中的

SET CLASSLIB TO。

using System;

using System.IO;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Data.Common;

using System.Data.OleDb;

using System.Diagnostics;

using System.Web;

using System.Web.Services;

namespace VFP7WebServiceExample

{

///

/// Service1 的摘要说明。

///

// 创建 ASP.NET Web Service。

public class Service1 : System.Web.Services.WebService

{

// 此方法是由 Visual Studio .NET 生成的。

public Service1()

{

// CODEGEN:该调用是 ASP.NET Web 服务设计器所必需的。

InitializeComponent();

}

// 这段代码是由 Visual Studio .NET 生成的。

#region 组件设计器生成的代码

///

/// 设计器支持所需的方法 - 不要使用

/// 代码编辑器修改此方法的内容。

///

private void InitializeComponent()

{

}

#endregion

///

/// 清理所有正在使用的资源。

///

protected override void Dispose( bool disposing )

{

}

// WebMethod 属性将该方法作为 Web Service 方法提供。

[WebMethod]

// 此方法将国家/地区作为参数接受并以 XML 格式的字符串

返回该国家/地区的所有客户记录。

public string CustomersInCountry(string strCountry)

{

string cReturnString;

注意: OLE DB 提供程序连接字符串的规范包括一个完整的驱动器和路径声明,用于在默认位置存储示例数据。如果您的数据位于其他位置,请对以下行进行相应的修改。


// 连接到 Visual FoxPro 数据库。

String strConnection = @"provider=VFPOLEDB.1 ;data

source='C:\PROGRAM FILES\MICROSOFT VISUAL FOXPRO

7\SAMPLES\DATA\TESTDATA.DBC';password='';user id=''";

OleDbConnection VFP7Connection = new OleDbConnection();

VFP7Connection.ConnectionString = strConnection;

VFP7Connection.Open();

// 创建带 select 语句的 Command 对象。

String strSelect = "SELECT * FROM customer WHERE

upper(country)='" + strCountry.ToUpper() + "'";

OleDbCommand VFP7SelectCommand = new

OleDbCommand(strSelect,VFP7Connection);

// 创建 DataAdapter。

OleDbDataAdapter VFP7DataAdapter = new OleDbDataAdapter();

VFP7DataAdapter.SelectCommand = VFP7SelectCommand;

// 创建 DataSet。

DataSet VFP7DataSet = new DataSet();

// 使用表信息填充 DataSet。

int iRecFound;

iRecFound = VFP7DataAdapter.Fill(VFP7DataSet,"Customer");

// 如果未找到客户记录,则返回空字符串。

if (iRecFound==0)

{

cReturnString = "";

}

else

{

// 如果找到客户记录,则将 DataSet 结果

写入 XML 并将其作为字符串返回。

StringWriter cXML = new StringWriter();

VFP7DataSet.WriteXml(cXML);

cReturnString = cXML.ToString();

}

return cReturnString;

}

}

}

要通过 Visual FoxPro 7.0 使用此 Web service,首先应创建一个 Web service 实例,然后将其分配给一个本地对象引用,如以下代码所示:

LOCAL oCustomers as ASPDotNetWS

LOCAL loWS, lcRetStr

* 初始化 ASP.NET Web service。


loWS = NEWOBJECT("Wsclient",HOME()+"ffc\_webservices.vcx")

loWS.cWSName = "ASPDotNetWS"

oCustomers = loWS.SetupClient

("http://localhost/VFP7WebServiceExample/VFP7WebService.asmx?WSDL",

上一页  1 2 3 4 5 6 7 下一页
  • 上一篇教程: 修复DBF数据表文件的简单方法
  • 下一篇教程: Visual Foxpro通用报表打印程序
  •  

    关于本站 | 广告联系 | 版权声明 | 使用帮助

    Copyright © 2004-2008 www.egunao.com All rights reserved.