C#连接嵌入式小型数据库firebird,操作数据
2018-01-26 17:15
691 查看
怎么创建数据库请参考
http://blog.csdn.net/u011511086/article/details/79174680
C#測試firebird嵌入式數據庫demo地址下載
https://pan.baidu.com/s/1dFZvNtZ
此示例demo的csdn下载地址
http://download.csdn.net/download/u011511086/10226084
數據庫下載:
https://www.firebirdsql.org/en/firebird-2-5-8/
.NET驅動下載
https://www.firebirdsql.org/en/additional-downloads/
C#示例代碼
https://www.firebirdsql.org/en/net-examples-of-use/
项目bin目录
报错解决:
http://blog.csdn.net/u011511086/article/details/79174680
C#測試firebird嵌入式數據庫demo地址下載
https://pan.baidu.com/s/1dFZvNtZ
此示例demo的csdn下载地址
http://download.csdn.net/download/u011511086/10226084
數據庫下載:
https://www.firebirdsql.org/en/firebird-2-5-8/
.NET驅動下載
https://www.firebirdsql.org/en/additional-downloads/
C#示例代碼
https://www.firebirdsql.org/en/net-examples-of-use/
项目bin目录
using FirebirdSql.Data.FirebirdClient; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data; namespace FirebirdTest { class Program { static void Main(string[] args) { //這裡的fbembed的版本是2.5.8 FbConnectionStringBuilder sb = new FbConnectionStringBuilder(); sb.ServerType = FbServerType.Embedded; //SYSDBA sb.UserID = "SYSDBA"; //masterkey sb.Password = "masterkey"; sb.Database = AppDomain.CurrentDomain.BaseDirectory.Replace("bin\\Debug\\", "") + "DB\\TEST.FDB"; FbConnection connection1 = new FbConnection(sb.ToString()); connection1.Open(); //事務 FbTransaction tran = connection1.BeginTransaction(); try { //插入 FbCommand cmd2 = connection1.CreateCommand(); cmd2.Transaction = tran; string sql2 = "INSERT INTO USERINFO (ID, NAME, SPASSWORD) VALUES (@id, @name, @password)"; cmd2.CommandText = sql2; cmd2.Parameters.Add(new FbParameter("@id", Guid.NewGuid().ToString())); cmd2.Parameters.Add(new FbParameter("@name", "歐陽修0")); cmd2.Parameters.Add(new FbParameter("@password", "sdf56756")); int count = cmd2.ExecuteNonQuery(); cmd2.Dispose(); //修改 FbCommand updateCmd = connection1.CreateCommand(); updateCmd.Transaction = tran; string sql_update = "update USERINFO set NAME='小萬1' where id='700A096E-5B28-7AF7-8D61-C3E0D0FF93FF'"; updateCmd.CommandText = sql_update; int count_up = updateCmd.ExecuteNonQuery(); updateCmd.Dispose(); tran.Commit(); } catch (Exception ex) { tran.Rollback(); } //查询 string sql = "select * from USERINFO"; FbCommand cmd = new FbCommand(sql, connection1); FbDataAdapter dp = new FbDataAdapter(cmd); DataTable dt = new DataTable(); dp.Fill(dt); dp.Dispose(); cmd.Dispose(); connection1.Close(); connection1.Dispose(); } } }
报错解决:
相关文章推荐
- C# 中有关数据库中数据的操作中,能否自连接
- C#连接SMO及数据库操作(一)
- C#学习中记录(二)--------数据库的连接操作
- c# .net 连接数据库操作
- c#数据库连接操作
- C#在winform中操作数据库,实现数据增删改查
- C#操作数据库(动态筛选和排序数据库数据)
- C#实现杀掉MSSQL中数据库当前连接的所有进程(进行数据还原的时候需要用到)
- C# 连接 SQL Server 2008 基础操作+数据库增删改查
- c# 命令行操作数据库并将数据导出到csv
- js 连接数据库如何操作数据库中的数据
- C#原生连接数据库并操作数据库的方法
- C#操作Access数据库之一(数据库的连接)
- 一步一步跟我学习hadoop(7)----hadoop连接mysql数据库执行数据读写数据库操作
- c# cs方式操作数据库 非使用sql连接字符串直接连接数据库
- Python教程:连接数据库,对数据进行增删改查操作
- 在ASP.NET 2.0中操作数据之七十:配置数据库连接和命令等级设置
- asp.netWeb开发中ztree实现无极限增删改查连接数据同步数据库操作
- 数据库连接:操作数据增删改查
- java 演示使用jdbc-odbc桥连接的方式操作数据库 向数据库中添加数据