带有C#的Advantage Database Server示例 [英] Advantage Database Server with C# Example

查看:145
本文介绍了带有C#的Advantage Database Server示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的开发人员,

问候,



我是Microsoft技术程序员,擅长C#。

需要你所有专家帮助来探索新领域,即



目前在我们的工作环境中,有一些基于xBASE(Cliper)的应用程序构建,数据库类型是.DBF / .NTX使用Advantage Database Server。



我到目前为止所做的是,我在PC上安装Windows Server 2008 R2然后安装ADS(Advantage Database Server)11.10( 30天试用版)然后我在驱动器D上复制一些.DBF文件:/



现在在另一台PC上我有OS XP和Visual Studio 2008广告VS2010。 />




现在我想制作一个测试C#应用程序,并使用ADS连接连接该Windows服务器的Drive D:/ Test.DBF文件。 br />


i有这样的小信息。



请帮我一些示例/演示应用程序。 />


谢谢



关于

S.Lal

S.america





•Advantage数据库服务器(c#)

如果您使用的是Microsoft Visual Studio,则可以从工具箱中直观地访问Advantage .NET数据提供程序组件。安装提供程序并启动Visual Studio后,打开工具箱(如果不可见,则在视图菜单下可用)并展开数据类别。右键单击并选择选择项目...这将打开一个对话框,允许您选择应在工具箱中显示哪些组件。您可以选择Advantage组件(AdsCommand,AdsConnection和AdsDataAdapter)。

•在项目中,添加对Advantage.Data.Provider的引用。例如,从Visual Studio .NET中,从项目菜单中选择添加引用...。 Advantage.Data.Provider应该在.NET组件列表中可用。如果不是,则可能需要运行Advantage .NET Data Provider安装。请注意,如果将其中一个可视组件从工具箱拖动到表单上,将自动添加对Advantage.Data.Provider的引用。

•指定源文件顶部的名称空间在任何声明之前。例如,使用C#,包含以下语句:

使用Advantage.Data.Provider;

在Visual Basic .NET中,使用以下语句:

Imports Advantage.Data.Provider

•声明并使用Advantage .NET数据提供程序类。

以下是连接到Advantage Database Server的简单示例,运行SELECT语句并将字段值打印到控制台。

C#示例:

//创建连接对象

AdsConnection conn = new AdsConnection( data source = c:\\data;+

ServerType = remote | local; TableType = ADT);

AdsCommand cmd;

AdsDataReader阅读器;

int iField;



试试

{



//与服务器建立连接

conn.Open();



//创建一个命令对象

cmd = conn.CreateCommand();



//指定一个简单的SELECT语句

cmd.C ommandText =select * from departments;



//执行语句并创建一个阅读器

reader = cmd.ExecuteReader();



//将查询结果转储到控制台

while(reader.Read())

{

for(iField = 0; iField< reader.FieldCount; iField ++)

Console.Write(reader.GetValue(iField)+);

Console.WriteLine();

}



conn.Close();

}

catch(AdsException e)

{

//打印异常消息

Console.WriteLine(e.Message);

}

Dear Developers,
Greetings,

I am Microsoft Technology Programmer, Good in C#.
Need you all expert help to explore new area, i.e

Currently at our work environment there is some Application build on xBASE(Cliper ) and data base type is .DBF / .NTX using Advantage Database Server.

What i did so far is, i install Windows Server 2008 R2 in on PC then i install ADS(Advantage Database Server) 11.10 ( 30 Days Trial Version ) then i copy some .DBF file on Drive D:/

now in another PC i have OS XP with Visual studio 2008 ad VS2010.


now i want to make a test C# application, and connect that Windows server's Drive D:/ Test.DBF file using ADS connection.

i have some small info like this.

Please help me with some sample / demo application.

thank you

with regards
S.Lal
S.america


• Advantage Database Server ( c# )
If you are using Microsoft Visual Studio, you can access the Advantage .NET Data Provider components visually from the Toolbox. After installing the provider and starting Visual Studio, open the Toolbox (available under the View menu if it is not visible) and expand the Data category. Right click and select "Choose Items…" This will open a dialog that allows you to select which components should be displayed in the Toolbox. You can select the Advantage components (AdsCommand, AdsConnection, and AdsDataAdapter).
• In your project, Add a reference to Advantage.Data.Provider. For example, from Visual Studio .NET, choose "Add Reference…" from the Project menu. Advantage.Data.Provider should be available in the .NET component list. If it is not, you may need to run the Advantage .NET Data Provider installation. Note that if you drag one of the visual components from the Toolbox onto a form, a reference to Advantage.Data.Provider will be added automatically.
• Specify the name space at the top of the source file prior to any declarations. For example, with C#, include this statement:
using Advantage.Data.Provider;
Within Visual Basic .NET, use this statement:
Imports Advantage.Data.Provider
• Declare and use the Advantage .NET Data Provider classes.
The following is a simple example that connects to Advantage Database Server, runs a SELECT statement and prints the field values to the console.
C# Example:
// create a connection object
AdsConnection conn = new AdsConnection( "data source=c:\\data;" +
"ServerType=remote|local; TableType=ADT" );
AdsCommand cmd;
AdsDataReader reader;
int iField;

try
{

// make the connection to the server
conn.Open();

// create a command object
cmd = conn.CreateCommand();

// specify a simple SELECT statement
cmd.CommandText = "select * from departments";

// execute the statement and create a reader
reader = cmd.ExecuteReader();

// dump the results of the query to the console
while ( reader.Read() )
{
for ( iField = 0; iField < reader.FieldCount; iField++ )
Console.Write( reader.GetValue(iField) + " ");
Console.WriteLine();
}

conn.Close();
}
catch ( AdsException e )
{
// print the exception message
Console.WriteLine( e.Message );
}

推荐答案

它不是那样的工作。

我们不为你工作。

如果你想让别人写你的代码,你需要付钱 - 我建议你去VWorker.com并在那里问。



但要注意:你得到你付出的代价。支付花生,获得猴子
It doesn't quite work like that.
We do not do your work for you.
If you want someone to write your code, you have to pay - I suggest you go to VWorker.com and ask there.

But be aware: you get what you pay for. Pay peanuts, get monkeys


这篇关于带有C#的Advantage Database Server示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆