使用 Visual C 连接到 MSSQL Server Express 并提取一些表数据的最少代码表达
我的计算机上安装了以下软件:
- Microsoft SQL Server Express 2005
- Microsoft Visual C++ Express 2008
我有一个 .mdf 文件,我需要从中读取一些数据并将其转储到文本文件。我可以使用 Visual Studio 中的数据库资源管理器浏览数据库文件,没有任何问题,但从应用程序连接时遇到问题。
我广泛搜索,几乎所有“解决方案”都说我应该开始一个新项目并选择“SQL Server 应用程序模板”,而我在模板中没有该模板。我发现的其他教程说我应该使用“数据源配置向导”,但是我在任何菜单中都找不到这样的向导。
我不介意点击,尽管我更希望所有这些都可以用纯 C++ 代码实现。比如:
DbConnection *d = new MSSQLConnection("local", "c:\path\to\file.mdf");
DbQuery *q = new DbQuery(d, "select * from mytable");
...dump the data and go home
谢谢。
或者,如果有人可以告诉我如何在 C++ 中执行此操作:
http:// Sharpertutorials.com/connecting-to-a-sql-server-database/
I have the following software installed on the machine:
- Microsoft SQL Server Express 2005
- Microsoft Visual C++ Express 2008
I have a .mdf file from which I need to read some data and dump to a text file. I can browse the database file using the Database Explorer in Visual Studio without any problem, but I'm having trouble connecting from the application.
I googled far and wide, almost all "solutions" say that I should start a new project and select the "SQL server application template", which I don't have amongst templates. Other tutorials I found say I should use "Data Source Configuration Wizard", however I cannot find such wizard in any of the menus.
I don't mind clicking although I would prefer if all this was doable in plain C++ code. Something like:
DbConnection *d = new MSSQLConnection("local", "c:\path\to\file.mdf");
DbQuery *q = new DbQuery(d, "select * from mytable");
...dump the data and go home
Thanks.
Alternatively, if someone can tell me how to do this in C++:
http://sharpertutorials.com/connecting-to-a-sql-server-database/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就是这样。一旦你知道了,就非常简单和容易......
And here it is. Quite simple and easy once you know it...
这对我有用
This Worked for me