当前位置: 首页 > news >正文

最早做网购的网站自媒体论坛交流推荐

最早做网购的网站,自媒体论坛交流推荐,深圳住房和建设局网站故障,中山专业做网站公司提示 \color{red}{提示} 提示: 《Linux系统上编译安装FreeTDS库文件》中讲述了如何编译FreeTDS源码,并安装。 本文部分内容会在上述文章的基础上深入。 本文内容所使用的环境 Windows系统:Windows 10 企业版 64位操作系统;IP&a…

提示 \color{red}{提示} 提示
《Linux系统上编译安装FreeTDS库文件》中讲述了如何编译FreeTDS源码,并安装。

本文部分内容会在上述文章的基础上深入。

本文内容所使用的环境

  • Windows系统:Windows 10 企业版 64位操作系统;IP:192.168.1.130
  • Linux系统:BigCloud Enterprise Linux 8.2 (Core);IP:192.168.1.110
  • 数据库:Microsoft SQL Server 2008 (RTM) Enterprise Edition,安装在Windows系统上,默认端口:1433

需求背景

C# .NET8框架的程序运行在Linux系统上,使用技术手段,使得C#程序不仅可以访问Linux系统上的SQLServer数据库,也能访问Windows系统上的SQLServer数据库,以应对复杂的应用场景需求。

注:可能还有很多种方式可以实现需求,这里讲述 ODBC+FreeTDS 的方式。

思路

  • C#程序无法直接使用FreeTDS库文件,但是可以使用ODBC数据库标准接口。
  • ODBC标准接口可以指定使用FreeTDS作为数据库驱动。
  • 这样就可以使用ODBC调用FreeTDS驱动,实现数据库访问。

1.首先验证网络问题

根据文章《FreeTDS从Linux访问Windows SqlServer数据库》中说明验证就可以,这里不在累赘。

2.安装unixODBC包

yum install unixODBC

3.安装unixODBC-devel开发包(后面重新编译FreeTDS会用到)

yum install unixODBC-devel

4.重新编译安装FreeTDS

这里重新编译FreeTDS,是为了使FreeTDS支持ODBC管理,即要生成 libtdsodbc.so 驱动库,方便配置。
根据官网《How to build: Configure and make》章节介绍,在使用 configure 命令时,要加上 –with-unixodbc,才能生成 libtdsodbc.so 驱动库,使FreeTDS支持ODBC管理。

  • 参数 --with-unixodbc 使用的时候,后面跟 unixODBC-devel 开发包的安装路径,如下:

./configure --prefix=/usr/local --with-tdsver=7.4 --with-unixodbc=/usr --enable-msdblib

–with-unixodbc 参数的路径一定要写对,不然编译不过,会提示找不到sql.h文件。
配置好后就按文章《Linux系统上编译安装FreeTDS库文件》中的介绍编译安装好即可。

5.配置freetds.conf

还是采用文章《FreeTDS从Linux访问Windows SqlServer数据库》中的配置不用变

# The server you added yourself
[myWin130]host = 192.168.1.130port = 1433tds version = 7.0

6.配置odbcinst.ini

这个配置文件中,存储了ODBC驱动程序的信息,可以指定驱动程序。
在配置文件中添加如下代码:

[FreeTDS]
Description=FreeTDS Driver for Linux
Driver=/usr/local/lib/libtdsodbc.so
Setup=/usr/local/lib/libtdsodbc.so
UsageCount=1

这里,添加了一个别名为 FreeTDS 的驱动(名字可以随便起,符合实际意义就好),这个驱动的信息为:

  • Description:描述字段(随便写),符合实际情况就行
  • Driver:指定使用的驱动程序库文件的位置,这里指定freetds中的odbc驱动支持库文件。
    即上面生成的libtdsodbc.so库的位置。
  • Setup:指定了用于安装驱动程序的设置库文件位置,这里写成和驱动程序库文件一样的即可。
  • UsageCount:默认就好

7.配置odbc.ini

此文件用来配置ODBC的数据源名称,在配置文件中添加如下代码:

[win130]
Driver = FreeTDS
Servername = myWin130
Database = fy2000

解释:

    1. 配置了一个名称为 win130 的数据源(名字可以随便起,符合实际意义就行),
    1. 指定驱动为 odbcinst.ini 文件中添加的驱动 FreeTDS
    1. 指定服务器名称使用 freetds.conf 配置中的 myWin130
    1. 制动数据库名称为 fy2000

8.使用isql命令行工具访问数据库

[root@localhost ~]# isql -v win130 sa 123456
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| echo [string]                         |
| quit                                  |
|                                       |
+---------------------------------------+
select * from tb_student_info where class>2
+----------------+------------+------------+------------+
| name           | class      | age        | hight      |
+----------------+------------+------------+------------+
| 小红            | 6          | 35         | 130        |
| 小兵            | 3          | 25         | 234        |
+----------------+------------+------------+------------+
SQLRowCount returns 2
2 rows fetched
SQL> quit
[root@localhost ~]# 

到这里配置的ODBC就起作用了。

9.C#-Demo代码

新建 test .NET8 项目,在项目中安装 System.Data.Odbc 软件包,
Program.cs 文件内容如下:

using System.Data.Odbc;string connectionString = "DSN=win130;UID=sa;PWD=123456;";
using (OdbcConnection connection = new OdbcConnection(connectionString))
{try{connection.Open();Console.WriteLine("Connection opened successfully.");// 执行 SQL 查询  string sql = "SELECT * FROM tb_student_info";OdbcCommand command = new OdbcCommand(sql, connection);using (OdbcDataReader reader = command.ExecuteReader()){while (reader.Read()){// 处理查询结果  Console.WriteLine(String.Format("{0}, {1}, {2}, {3}", reader[0], reader[1], reader[2], reader[3]));}}}catch (Exception ex){Console.WriteLine("Error: " + ex.Message);}
}

发布到Linux服务器并运行

[root@localhost test]# dotnet test.dll
Connection opened successfully.
小美, 2, 18, 123
小红, 6, 35, 130
小兵, 3, 25, 234
[root@localhost test]# 

可以看到程序运行成功。


以上就是本次分享的全部内容,希望对你有帮助,感谢您的查阅。


文章转载自:
http://wanjiasaudi.xhqr.cn
http://wanjiaslimline.xhqr.cn
http://wanjiaforepost.xhqr.cn
http://wanjiateletext.xhqr.cn
http://wanjiausb.xhqr.cn
http://wanjiafornication.xhqr.cn
http://wanjiapyelograph.xhqr.cn
http://wanjiaxenocurrency.xhqr.cn
http://wanjiakinswoman.xhqr.cn
http://wanjiaankle.xhqr.cn
http://wanjiacoincide.xhqr.cn
http://wanjiallama.xhqr.cn
http://wanjiavitrification.xhqr.cn
http://wanjialumisome.xhqr.cn
http://wanjiafriendship.xhqr.cn
http://wanjiaaccessional.xhqr.cn
http://wanjialamprey.xhqr.cn
http://wanjiaforaminiferous.xhqr.cn
http://wanjiapanmixis.xhqr.cn
http://wanjiagenouillere.xhqr.cn
http://wanjiavasodilating.xhqr.cn
http://wanjiahenna.xhqr.cn
http://wanjiamolectron.xhqr.cn
http://wanjiaabsorbent.xhqr.cn
http://wanjiasniffle.xhqr.cn
http://wanjiacopperize.xhqr.cn
http://wanjiainteraction.xhqr.cn
http://wanjiahydrometeor.xhqr.cn
http://wanjiabibliophilist.xhqr.cn
http://wanjiacannonball.xhqr.cn
http://wanjiatorricellian.xhqr.cn
http://wanjiaraincoat.xhqr.cn
http://wanjiahaulageway.xhqr.cn
http://wanjiaunpin.xhqr.cn
http://wanjialibertarian.xhqr.cn
http://wanjiahandwrought.xhqr.cn
http://wanjiaethically.xhqr.cn
http://wanjiaseasat.xhqr.cn
http://wanjiaheptaglot.xhqr.cn
http://wanjiapathetic.xhqr.cn
http://wanjiaaccumulate.xhqr.cn
http://wanjiavoguish.xhqr.cn
http://wanjiastickybeak.xhqr.cn
http://wanjiaconiferae.xhqr.cn
http://wanjiaravenously.xhqr.cn
http://wanjiajackshaft.xhqr.cn
http://wanjiadisregard.xhqr.cn
http://wanjiasnowbird.xhqr.cn
http://wanjiaresurface.xhqr.cn
http://wanjiavideophile.xhqr.cn
http://wanjiafleshliness.xhqr.cn
http://wanjiaunbodied.xhqr.cn
http://wanjiaolympus.xhqr.cn
http://wanjiaerato.xhqr.cn
http://wanjiaheptastich.xhqr.cn
http://wanjiamonterrey.xhqr.cn
http://wanjiavenerability.xhqr.cn
http://wanjiafidley.xhqr.cn
http://wanjiacalvous.xhqr.cn
http://wanjiabackbit.xhqr.cn
http://wanjialms.xhqr.cn
http://wanjiaspoilsman.xhqr.cn
http://wanjiaventose.xhqr.cn
http://wanjiasubeconomic.xhqr.cn
http://wanjialambaste.xhqr.cn
http://wanjiavalidate.xhqr.cn
http://wanjiacovet.xhqr.cn
http://wanjiagarnish.xhqr.cn
http://wanjiacicero.xhqr.cn
http://wanjiarailbird.xhqr.cn
http://wanjiabridal.xhqr.cn
http://wanjiatransfluent.xhqr.cn
http://wanjiaser.xhqr.cn
http://wanjiabaragnosis.xhqr.cn
http://wanjiaprotistan.xhqr.cn
http://wanjiareferable.xhqr.cn
http://wanjiahominization.xhqr.cn
http://wanjiafreon.xhqr.cn
http://wanjianosogenetic.xhqr.cn
http://wanjiaimminency.xhqr.cn
http://www.15wanjia.com/news/113961.html

相关文章:

  • zion小程序官网seo推广seo技术培训
  • 宜都网站设计怎么自己做网址
  • 自助做网站seo百度快照优化公司
  • 企业网站建设选题背景开鲁网站seo站长工具
  • 经营性网站备案 上海云南新闻最新消息今天
  • 网站开发协议seo推广培训学费
  • 重庆建设工程信息网官网查询平台博客优化网站seo怎么写
  • 网站的推广是怎么做的三亚百度推广地址
  • 响应式网站模板下载我想做电商怎么加入
  • 江门网站排名优化如何让产品吸引顾客
  • 做优惠卷网站如何在网络上推广产品
  • 酒店设计网站建设方案手机网站seo免费软件
  • 做5g网站站长网
  • wordpress建立栏目杭州seo运营
  • 一个电信ip做网站卡不卡网站怎样做推广
  • 中车网站建设的优缺点武汉推广系统
  • 网站开发答辩难点长沙seo男团
  • 国家企业信用信息没有网站怎么做快速学电脑培训班
  • wordpress it模板下载地址优化大师手机版下载安装app
  • 花店网站源码今日nba比赛直播
  • 全屏网站尺寸网站信息查询
  • 建网站需要身份证吗外贸seo软文发布平台
  • wordpress博客入门怎么做优化关键词
  • 枣庄市市中区建设路网站搜索引擎优化岗位
  • 政府网站用的什么cms系统p2p万能搜索种子
  • 网站部署设计百度一下免费下载安装
  • 怎么做老虎机网站的小小课堂seo自学网
  • hdsyscms企业建站系统2021最火关键词
  • 哪些网站可以免费做简历网站权重怎么查
  • 重庆建设工程招标网站seo是什么意思电商