How To Rebind to Server in GO - sql-server

I am writing a Go Web App that displays data to a webpage. The database is in Microsoft SQL Server 2008. When running the program, the URL is properly handled in the main function to a function WebHandler() using ListenAndServe on Port 8080, but as soon as I connect to the SQL database, the web server connection is lost.
WebHandler() connects to the sql database, fills struct values with sql results, and loads the struct into an html/template to fill out a table accordingly.
I am using the github.com/LukeMauldin/lodbc" and "github.com/jmoiron/sqlx" packages to get sql results and they display fine. How do I reestablish the webservice in the WebHandler Function?

The issue was that I was trying to connect to the sql database on every page. The key is to connect only once and defer the close

Related

Copy all data from local to server and server to local

I have a win form app which is running at local using SQL Server database. The second database is at server and working. Because of internet connection problem I don't save data to server all time. My aim is that how can I copy (mirroring) data in local database to server database and copy data from server to local when added or changed data. There are foreign key problems etc.
My last goal is reach, add, or edits data from remotely on mobile or website. I tried signalR Socket it is good when local machine has connection. When connection lost I can't reach local database with signalR.

Failed to retrieve data (SQL Server Authentication)

I am trying to connect to a database created in the SQL Server 2016 express edition, through Data Source Configuration Wizard in VS2017 Express edition, with SQL Server Authentication.
I created the user in SQL Server, and when I test the connection works perfectly, but vs displays the error. Also in Server properties, I set up SQL and Windows authentication.
I finally found a solution. I checked the checkbox remember password while creating connection string...and now can retrieve data for that user. In connection string is added persisted security=true. Still don't know why this need to be checked, because I follow example without persisted security, and there it worked, but on my PC didn't.

How does Sql server will identify Tomcat server?

I have number of applications in Tomcat server and I have sql server 2012 Database. Initially the Database will send the message to application says that database getting changed. Then the application(Tomcat server) fire the query to fetch the data from database.
In my scenario user doesn't have access to application(java, webMathematica, etc.) he has only access to Database to modify data. Initially I start the tomcat server and sql server then I can use JDBC driver to connect application server to sql server.
Now I want know whether database can identify the tomcat server before application server establish the connection to database server to send the message about the data updation.

Can't access SQL Server file in the server machine

I setup the my WCF service on server machine.
The server OS is Windows 2008 with SQL Server 2008 Express.
I am trying to access to my SQL Server (mdf) file to read data using LINQ to SQL.
I see that the DataContext is OK - but when I try to get information that in one of the table I get an exception
Failed to generate a user instance of
SQL Server due to failure in
retrieving the user's local
application data path. Please make
sure the user has a local user profile
on the computer. The connection will
be closed.
I don't know what i need to define or change in the IIS 7.5 that I'm using in the server side.
Thanks for any help.
Update: the connection to the database file is fine - but getting information from table is thru an exception. The connection string is:
Data Source=.;AttachDbFilename=|DataDirectory|\ServiceData.mdf;
Integrated Security=SSPI;User Instance=True
If you already have a server, why don't you just attach the MDF to the SQL Server (Express) running, and then use it like a normal database on your server?
After you do this, use a connection string like:
server=Server\SQLExpress;Database=YourDatabaseName;Integrated Security=SSPI
I never quite liked the AttachDbFileName= and User Instance approach - seems like a (unreliable) hack to me, which really doesn't make sense if you're running on a server machine.
The reason that you are getting this error message is because your code is in the security context of a user that has never logged on to the server. The user therefore does not have a profile and you therefore get an error when the code attempts to write to a non-existant profile.
You could use marc_s's approach or you could run as a user that has a profile.

In Excel 2007, link to a SQL Server DB with the data connection not possible

I have data in a SQL Server 2008 db and I want to get the reporting in Excel.
I have created view for that and I want to link them to Excel using the Data / Connection tool available in Excel 2007.
When I do the import in Excel from the SQL Server on the server machine (ie, where the SQL Server is running) everything is fine and I can refresh manually or automatically (which is what I'm looking for).
But when I try to refresh (or do the link) from an other machine it does not work: I have the following message " [DNETLIB][ConnectionOpen (Connect()).]SQLServer does not exist or access denied "
The TCP IP protocol is available on the server and a telnet on the port 1433 is working.
So I don't know what could be the problem. Any idea?
You could try adding: namedPipe=true to the connection string.
Can you connect via any other method from the client machine i.e. using SQL Server Tools? Establish whether it is Excel or general connectivity issue first.

Resources