.net + firebird实现内置数据库的桌面程序_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > .net + firebird实现内置数据库的桌面程序

.net + firebird实现内置数据库的桌面程序

 2013/7/23 12:41:11  josephgao  程序员俱乐部  我要评论(0)
  • 摘要:1.下载firebirdhttp://www.firebirdsql.org/en/server-packages/笔者选的是2.5.22.解压,进入bin目录,install_super.bat3.我的电脑右键->管理->服务,将firebird的服务置成手动4.可选,下载一个firebird的client,笔者选的是FlameRobin还挺好用的至此,可以试试firebird了,可以使用firebird/bin/isql,CREATEDATABASE'firstdb
  • 标签:程序 .net 实现 net 数据库 数据
1. 下载firebird http://www.firebirdsql.org/en/server-packages/笔者选的是2.5.2
2.  解压,进入bin目录,install_super.bat
3.  我的电脑右键->管理->服务,将firebird的服务置成手动
4.  可选,下载一个firebird的client,笔者选的是FlameRobin还挺好用的
至此,可以试试firebird了,可以使用firebird/bin/isql,
CREATE DATABASE 'firstdb.gdb' USER 'sysdba' PASSWORD 'masterkey';
然后使用客户端去操作一下,比较标准的sql语言
5.  下载.net的连接firebird的库, .net provider http://www.firebirdsql.org/en/net-provider/,请注意与你工程的.net版本匹配.
6.   将dll引用到工程中,右键点击右侧引用,添加...
7.   
class="c#" name="code">
class Helper
    {
        private static Helper helper = new Helper();
        private FbConnection cn ;
        private Helper(){
            FbConnectionStringBuilder cs = new FbConnectionStringBuilder();
            cs.DataSource = "127.0.0.1";
            cs.Database = @"C:\HOUSENUMBER.FDB";
            cs.UserID = "sysdba";
            cs.Password = "masterkey";
            //Console.WriteLine(Directory.GetFiles(@"../").ToString());
            //cs.Dialect = 1;
            cn = new FbConnection();
            cn.ConnectionString = cs.ToString();
            cn.Open();
        }
        public static Helper getInstance()
        {
            if(helper == null){
                helper = new Helper();
            }
            return helper;
        }

        public void destroy()
        {
            if (cn != null)
            {
                cn.Close();
            }
        }

        public void delete(int areaNo, int buildingNumber, String roomName)
        {
            FbCommand cmd = cn.CreateCommand();
            String sql = "delete from ROOM where AREANO = " + areaNo + " and BUILDINGNUMBER = " + buildingNumber + " and NAME = '" + roomName+"'";
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();
        }

        public void add(RoomBean bean)
        {
            String sql ="INSERT INTO ROOM (NAME, BUILDINGNUMBER, FLOOR, ACTUALAREA, PUBLICAREA, TOTALAREA, PUBLICRATIO, UNDERNUMBER, UNDERNAME, UNDERFLOOR,"+
            "UNDERACTUAL, UNDERPUBLIC, UNDERTOTAL, ISRESERVED, ISTOKEN, BUILDINGLEVEL, AREANO)"
                    + "VALUES ('" +
                    bean.getName() + "', " +
                    bean.getBuildingNumber() + ", " +
                    bean.getFloor()+ ", " +
                    bean.getActualArea()+ ", " +
                    bean.getPublicArea()+", " + 
                    bean.getTotalArea()+ ", " + 
                    bean.getPublicRatio()+ ", '" + 
                    bean.getUnderNumber() + "', '" + 
                    bean.getUnderName() + "', " + 
                    bean.getUnderFloor() + ", " + 
                    bean.getUnderActual()+ ", " + 
                    bean.getUnderPublic() + ", " + 
                    bean.getUnderTotal() + ", " + 
                    bean.getIsReserved()+ ", " + 
                    bean.getIsToken()+ ", " + 

                    bean.getBuildingLevel()+ ", " + 
                    bean.getAreaNo() + ")";
            
            FbCommand cmd = cn.CreateCommand();
            cmd.CommandText = sql;
            cmd.ExecuteNonQuery();

        }
}

笔者写的一些简单例子
上一篇: 世界上最值钱的10幅照片 下一篇: 没有下一篇了!
发表评论
用户名: 匿名