英文:
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/sql 和 github.com/denisenkom/go-mssqldb 驱动程序。
英文:
Try database/sql with the github.com/denisenkom/go-mssqldb driver.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论