db icon indicating copy to clipboard operation
db copied to clipboard

does it support mssql with odbc connection?

Open ringrid opened this issue 9 years ago • 2 comments

In real sence I need odbc connection for mssql,but I found it's documents with url method only. does it support for odbc connection?

ringrid avatar Jun 09 '17 08:06 ringrid

Not directly, but the mssql.Open function expects an argument of type db.ConnectionURL so you can provide your own connection string by providing any struct that satisfies db.ConnectionURL:

type odbcConnectionURL struct {
  dsn string
}
func (odbc odbcConnectionURL) String() string {
  return odbc.dsn
}

settings := odbcConnectionURL{"odbc:server=localhost;user id=sa;database=master;connection timeout=30"}

conn, err := mssql.Open(settings)
...

Does this work for you?

xiam avatar Jun 10 '17 12:06 xiam

It was work, and I have tried ado Connection with options: {"encrypt": "disable"},It was work too. Thanks a lot. ^_^

ringrid avatar Jun 11 '17 07:06 ringrid