0
I am trying to use a select in my SQL Server Database that I have in Azure.
I’m using the Driver: https://github.com/denisenkom/go-mssqldb.
However, a message is returned to me:
mssql: Invalid Object name 'dbo.table'.
Below my code, where I’m wrong?
package main
import (
_ "github.com/denisenkom/go-mssqldb"
"database/sql"
"log"
"fmt"
)
func main() {
connectionDB() // inicia conexão com o azure
}
func connectionDB() {
log.Println("Main:")
log.Println("Opening")
db, err := sql.Open("mssql", "server=pwbt.database.windows.net;Initial Catalog=dbo;user id=admin-jose;password=password") //deixei a senha errada para postar aqui
if err != nil {
log.Println("Open Failed: ", err.Error())
}
log.Println("Opened")
log.Println("Pinging")
err = db.Ping();
if err != nil {
log.Println("Failed to ping: ", err.Error())
}
log.Println("Pinged")
x := 2
rows, err := db.Query("select Nome from dbo.tbPessoa where Id=?", x)
if err != nil {
log.Fatal(err)
}
defer rows.Close()
defer db.Close()
fmt.Println(rows)
fmt.Printf("bye\n")
}
Return:
C: Go bin go.exe run B: go gocode src main connect-bd.go
2017/02/25 15:59:33 Main:
2017/02/25 15:59:33 Opening
2017/02/25 15:59:33 Opened
2017/02/25 15:59:33 Pinging
2017/02/25 15:59:33 Pinged
2017/02/25 15:59:33 mssql: invalid Object name 'dbo.tbPessoa'.
Exit status 1