作为程序员无论是我们写的各种MIS系统还是游戏都离不开数据的存取 操作 ,正如我们前几天在VS下做的一MIS系统,现在纠结。 如果是C/S或B/S模型就好了,可是需求不是,没办法,顾客是上帝。。。他们的需求是 本地 化对 数据库 就直接进行 操作 (在不安装sqls
作为程序员无论是我们写的各种MIS系统还是游戏都离不开数据的存取操作,正如我们前几天在VS下做的一MIS系统,现在纠结。
如果是C/S或B/S模型就好了,可是需求不是,没办法,顾客是上帝。。。他们的需求是本地化对数据库就直接进行操作(在不安装sqlserver的情况),弟兄们有解决的办法吗,求支招???
众里寻他千百度,GSQL却在我内心深处。唉呀,现在觉得有盼头了,问题大概能解决了,接下来就下载了 GSQL_6.5.0.4
下载链接 http://www.powerip.net/GSQL/GSQL_6.5.0.4.rar
下面就开始配环境了
1,先解压
2,双击Gsql.exe
如果无响应,强制关掉,重启。
3,服务已经打开了,接着是数据库了
记得将数据哭的路径转化为相对路径哦!在这里我就不再啰嗦了,网上有教程的。
下面的链接代码:
<span>using</span><span> System; </span><span>using</span><span> System.Collections.Generic; </span><span>using</span><span> System.Data.SqlClient; </span><span>using</span><span> System.Linq; </span><span>using</span><span> System.Text; </span><span>namespace</span><span> pharmacopeia { </span><span>///</span> <span><summary></summary></span> <span>///</span><span> <strong>数据库</strong>连接层 </span><span>///</span> <span></span> <span>public</span> <span>class</span><span> CDbResource { </span><span>///</span> <span><summary></summary></span> <span>///</span><span> <strong>数据库</strong>的连接对象 </span><span>///</span> <span></span> <span>private</span> <span>static</span><span> SqlConnection _con; </span><span>///</span> <span><summary></summary></span> <span>///</span><span> 获取<strong>数据库</strong>的链接对象 </span><span>///</span> <span></span> <span>public</span> <span>static</span><span> SqlConnection Connection { </span><span>get</span> { <span>return</span><span> _con; } } </span><span>///</span> <span><summary></summary></span> <span>///</span><span> 静态构造函数,初始化<strong>数据库</strong>连接 </span><span>///</span> <span></span> <span>static</span><span> CDbResource() { </span><span>string</span> connection = <span>"</span><span>Server = '</span><span>"</span> <span>127.0</span>.<span>0.1</span><span>"</span><span>,7788';Database = pharmacopeia;User Id=sa;Password=admin;Trusted_Connection = False;MultipleActiveResultSets = true</span><span>"</span><span>; _con </span>= <span>new</span><span> SqlConnection(connection); _con.Open(); } </span><span>///</span> <span><summary></summary></span> <span>///</span><span> 静态接口,释放<strong>数据库</strong>连接 </span><span>///</span> <span></span> <span>public</span> <span>static</span> <span>void</span><span> disposeConnection() { _con.Close(); } } }</span>
运行结果:
其实很简单,真的不用安装sqlserver就搞定了,可以试一下,有问题共同学习哦!