惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - YiStudio

在Word中插入图片 DataGridView多列排序 将Word嵌入到自己的程序中 一个非常不错的压缩组件 免费的国产报表Grid++Reprot 使用NSIS制作安装包(2) 使用NSIS制作安装包(1) SharpDevelop2.0 用Firebird .NET Data Provider编写.NET应用程序(2) 用Marathon管理Firebird数据库(2) 用Marathon管理Firebird数据库(1) Firebird简介 NDoc修改手记(三) NDoc修改手记(二) NDoc修改手记(一) WebForm中将DataGrid中导出数据的方法 FxCop EXCEL2003中使用XML 动态加载类(动态加载DLL文件)
用Firebird .NET Data Provider编写.NET应用程序(1)
YiStudio · 2005-07-04 · via 博客园 - YiStudio

Firebird .NET Data Provider是一个用来操作Firebird数据库的数据访问组件,目前的版本是1.7。该组件提供了访问和操作Firebird数据库的各种函数,其使用非常简单,使用符合ADO.NET的规范。因此在使用上我们不会有太大的陌生感。

在安装Firebird .NET Data Provider后,其提供了一个SDK文档,通过它,我们可以快速的了解并使用该组件。

在编写一个数据库应用程序的时候,第一步肯定是建立一个和要操作数据库的连接,一般我们都是使用连接字符串,而通常情况下,这个连接字符串是比较复杂的,不是十分容易记忆。Firebird .NET Data Provider提供了一个名为FbConnectionStringBuilder的类,通过它我们可以很方便的构造一个连接字符串。

 FirebirdSql.Data.Firebird.FbConnectionStringBuilder cs=new FirebirdSql.Data.Firebird.FbConnectionStringBuilder();
 cs.DataSource="localhost";
 cs.Database=@"d:\firebird\firsttest.gdb";
 cs.UserID="sysdba";
 cs.Password="masterkey";
 cs.Dialect=1;
 
 FirebirdSql.Data.Firebird.FbConnection cn=new FirebirdSql.Data.Firebird.FbConnection();
 cn.ConnectionString=cs.ToString();
 
其后操作数据库的方法就和使用ADO.NET操作SQL Server或是Access数据库没什么区别了(除了使用的类名称不同外)。

下面是填充数据集的代码
     cn.Open();
     string strSQL="select * from T_1";
     FirebirdSql.Data.Firebird.FbDataAdapter ad=new FirebirdSql.Data.Firebird.FbDataAdapter(strSQL,cn);
     System.Data.DataSet ds=new System.Data.DataSet();
     ad.Fill(ds);
     cn.Close();
 
下面是向已连接的数据库中插入记录
     cn.Open();
     string strSQL="insert into T_1 values("1,'2005-7-4','testvalue')";
     FirebirdSql.Data.Firebird.FbCommand cm=new FirebirdSql.Data.Firebird.FbCommand();
     cm.Connection=cn;
     cm.CommandType=System.Data.CommandType.Text;
     cm.CommandText=strSQL;
     cm.ExecuteNonQuery();
     cn.Close();