I asked this question on the CSDN forum, but no one talked me about it, and I finally got it done.
The original link, there is no solution, the following provides a workaround.
Confirm that the SQL Server service is open
First, manage access from my Computer, right-click
Confirm that the SQL Server service is open.
You can also use cmd (Command Line window), open cmd as an administrator, enter
netstart[服务名]
The effect is as follows:
If there are spaces in the middle of the service name, be sure to add double quotes.
Configure ODBC
See links for specific methods.
Be sure to note that the server name in the code must be the name of the data source, which is the "SQLSERVER2008_ODBC" in the connection.
Second, your username and password will also be the password to set the data source, i.e. "sa" and * * * * * * * * * *.
Finally, be sure to verify that the test was successful.
Code issues
Grammar I do not say here, but please do not write wrong.
In general, this is the wrong step.
In the code, make sure your SY (data source name), DB2 (username), pass (password), must be the same as your data source settings and SQL Server settings.
Engineering issues created
I am stuck at this point above.
Generally speaking, we will use the WIN32 console application to write C + +. But if you're creating that project, you can't even do it. You can try VC + +, there may be no such restrictions.
Be sure to create an empty project with VC + +
By this step, it can be solved successfully.
If there is a problem, then GG (but it is estimated that it is the problem of the code).
VS Connect SQL Server solution with C language