简体   繁体   English

使用C#.net在FoxPro数据库中插入/选择数据

[英]Insert/Select data in foxpro database using c# .net

I want to use FoxPro database in backend and c# .net in front end but i don't know how to connect with foxpro database in .net 我想在后端使用FoxPro数据库,在前端使用c#.net,但我不知道如何与.net中的FoxPro数据库连接

For connectivity what code i use, please suggest... 对于连接性,我使用什么代码,请提出建议...

You may want to look at .Net Interop. 您可能需要查看.Net Interop。

Also take a look at West-Wind web connect. 还可以看看West-Wind Web连接。 They have a framework that allows you to use the Visual studio IDE to create webforms but also use your VFP business logic and data source. 他们拥有一个框架,该框架使您可以使用Visual Studio IDE创建Web表单,还可以使用VFP业务逻辑和数据源。 This works well. 这很好。

West wind also has a wwDotNetBridge that allows you to access .Net components from VFP. 西风还拥有一个wwDotNetBridge,它使您可以从VFP访问.Net组件。

Check out their website below. 在下面查看他们的网站。

http://west-wind.com/WestwindClientTools.aspx http://www.west-wind.com/presentations/VFPDOTNETiNTEROP/VFPDOTNETINTEROP.HTM http://west-wind.com/WestwindClientTools.aspx http://www.west-wind.com/presentations/VFPDOTNETiNTEROP/VFPDOTNETINTEROP.HTM

I don't think you necessarily need to go the way of "interop", but get a basic understanding of connecting and querying data. 我认为您不一定需要走“互操作”的方式,而是对连接和查询数据有基本的了解。

First, get Microsoft's OleDB provider located here 首先, 在此处获取Microsoft的OleDB提供程序

Here is a sample doing a connection and running a simple query to get data but this one sends the results to another VFP table instead of bringing back to C# for process/usage. 这是一个进行连接并运行简单查询以获取数据的示例,但此示例将结果发送到另一个VFP表,而不是返回C#进行处理/使用。

This example shows Inserting records and uses parameters to help prevent any attempts at SQL-injection attacks 此示例显示插入记录并使用参数来帮助防止任何尝试进行SQL注入攻击的尝试

And another using SQL-Update 另一个使用SQL-Update

Once you get the basics down, its not that difficult. 一旦掌握了基础知识,就没有那么困难了。 I've actually made a simple "wrapper" class to centralize ensuring a valid connection, execute a given query and closing connection when done. 实际上,我已经制作了一个简单的“包装”类,以集中确保有效的连接,执行给定的查询并在完成后关闭连接。 Then, I've just added methods to it for each thing I wanted to do (or could be subclassed too). 然后,我为想要做的每件事添加了方法(也可以将其子类化)。 Anyhow, when I need to do a certain action, I would just call that function and pass in whatever parameter(s) was(were) needed. 无论如何,当我需要执行某些操作时,我只需要调用该函数并传入需要的任何参数即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM