连接到Go Lang中的SQL Server 2014

huangapple go评论89阅读模式
英文:

Connect to SQL Server 2014 in Go Lang

问题

我在Windows 7机器上使用以下代码成功连接到SQL Server 2008 R2的数据库:

db, err = sqlx.Open("lodbc", connString)

我导入了以下包:

"github.com/LukeMauldin/lodbc"
"github.com/jmoiron/sqlx"

但是,现在我将相同的驱动程序和连接字符串更改为位于远程Windows 8机器上的2014 SQL Server数据库时,我可以成功连接,但是在执行sqlx查询时出现错误:

datasource 2015/03/23 09:09:37 http: panic serving 127.0.0.1:49346: {IM002} [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

是否有其他驱动程序可用?我尝试了code.google.com/p/odbc和database/mssql包,但它们都不起作用。

谢谢。

英文:

I had a working database connection on a windows 7 machine to SQL Server 2008 R2 using:

     db, err = sqlx.Open("lodbc", connString)

importing the following packages

     "github.com/LukeMauldin/lodbc"
     "github.com/jmoiron/sqlx"

But now using the same driver and changing the connection string to a 2014 SQL Server database located on a remote windows 8 machine, I get a successful connection but a sqlx query breaks saying

> datasource 2015/03/23 09:09:37 http: panic serving 127.0.0.1:49346: {IM002} [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Is there another driver I can use? I tried code.google.com/p/odbc and database/mssql packages and those didn't work.

Thanks

答案1

得分: 6

尝试使用 database/sqlgithub.com/denisenkom/go-mssqldb 驱动程序。

英文:

Try database/sql with the github.com/denisenkom/go-mssqldb driver.

huangapple
  • 本文由 发表于 2015年3月23日 22:25:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/29212758.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定