Comments (4)
Hi @trustieee - It looks like str3 should work if you reverse the ""
Try: str3 := "server=localhost\mssqlserver2022;user id=sa;password=sa;database=FooDB"
If that does not work for you then another approach is to log into the SQL instance you wish to connect to with SSMS or ADS and look at the startup messages in the SQL error log to see which port SQL is listening on. Once you know the port you can do something like:
"server=localhost,61821;user id=sa;password=sa;database=FooDB" or "server=localhost;port=61821;userid=sa;password=sa;database=FooDB"
Please let us know if that helps.
from go-mssqldb.
Thanks @dlevy-msft ,
It seems the issue may be related to how the app is being ran. It's being ran inside WSL.
If I copy/paste my code to my windows environment, it works.
So perhaps there needs to be additional configuration to allow the app to connect to MSSQLServer running on Windows from a go app running inside WSL?
from go-mssqldb.
@trustieee - yes it does, have you run through the steps in this doc?
https://learn.microsoft.com/en-us/windows/wsl/networking
from go-mssqldb.
@dlevy-msft thank you, that was the issue.
For anyone else seeing this in the future, my SQL server was using a named instance (not the default name assigned to the sql server when you create/install it), and as such it had a dynamic port assigned to it. I had to retrieve the port using the SQL Server Configuration Manager, under the TCP protocol, and then had to allow that port on my Windows host firewall. I also had to retrieve the IP address of my Windows host (ipconfig
in a terminal), and use that as part of my connection string.
In the end, my working connection string looks like this:
connectionString := `server=192.168.x.x\mssqlserver2022;user id=sa;password=sa;database=PeopleDB`
from go-mssqldb.
Related Issues (20)
- Connection Error 17830 logged to extended events when connecting to servers with multiple IPs
- QueryContext blocks when the network is down HOT 4
- String output parameter value is cut off HOT 18
- can i use always encrypted with secure enclaves? HOT 1
- Use dockertest to instantiate the test database HOT 2
- Is There Support For The HierarchyID Data Type? HOT 3
- tdsBuffer data race in transaction query with OUTPUT HOT 1
- connection not closed when database name is incorrect HOT 1
- Support prelogin response with packet type 4
- port number added to AKV urls breaks things HOT 1
- Out param with Dest type sql.NullString cut to 4000 chars HOT 4
- DATETIME rounding does not match SQL Server documentation HOT 1
- How can I send a list in the select query with IN? HOT 2
- UUID wrong binding problem HOT 1
- Fetched Row Count Not Match With Source Table Row Count HOT 4
- `sql_variant` invalid `scanType` value
- No support of bulkcopy an IMAGE column
- how to transfer data to tvp with special characters in the name
- cannot connect to MSSQLSERVER on localhost: "No connection could be made because the target machine actively refused it" HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-mssqldb.