___ ___ erkimt Message "Invalid object name 'dbo.table' SQL Server Go Lang ______ qstntxt ___

I'm trying to use a select in my SQL Server Database that I own in Azure.

I'm using the Driver: link .

However, I get a message back:

  

mssql: Invalid object name 'dbo.table'.

Below my code, where am I wrong?

%pre%

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

    
______azszpr186720___

In my connect string, I was missing out on which bank to use %code%

Done this connected in a good!

Without this information Select was being done in the default SQL master database.

It looks like this:

%pre%     

___
0

I'm trying to use a select in my SQL Server Database that I own in Azure.

I'm using the Driver: link .

However, I get a message back:

  

mssql: Invalid object name 'dbo.table'.

Below my code, where am I 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

    
asked by anonymous 25.02.2017 / 20:18

1 answer

3

In my connect string, I was missing out on which bank to use database=PWBT.

Done this connected in a good!

Without this information Select was being done in the default SQL master database.

It looks like this:

db, err := sql.Open("mssql", "server=pwbt.database.windows.net;user id=admin-jose;password=password;database=PWBT;port=1433")
    
25.02.2017 / 21:29