VB.Net VS 2010 SQL连接问题 [英] VB.Net VS 2010 SQL Connection Issues

查看:126
本文介绍了VB.Net VS 2010 SQL连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试为我的公司创建一个简单的小程序,该程序将允许管理人员在文本匹配过程中输入计算机名称,然后查询我们的WMI数据库并提取该计算机的软件信息.

代码:

Hello All,

I am trying to create a simple little program for my company that will allow management people to input a computer name into a text hit process, and it query our WMI database and pull the software information for that computer.

CODE:

Dim ConnectionString As String = "Data Source=LANSWEEPER\SQLEXPRESS;Initial Catalog=lansweeperdb;User ID=sa;Password=MYsaPASSWORD;Connect Timeout=30"
 
Dim Connection As New System.Data.SqlClient.SqlConnection(ConnectionString)
 
Dim command As New System.Data.SqlClient.SqlCommand("SELECT a.Username, a.ComputerUnique, c.softwareName, c.softwareVersion, c.SoftwarePublisher FROM dbo.tblComputers a RIGHT JOIN dbo.tblUsers b ON b.Computername = a.Computername JOIN dbo.tblSoftware c ON c.Computername = a.ComputerName WHERE a.ComputerUnique = CORP\" & My.Resources.ComputerName & "\1", Connection) 



如果我在数据源中只有一个"\",则会出现语法错误,如果我有两个"\",则表明该程序找不到该实例.

SQL Server的配置正确,因为我们有一个用于帮助台与系统交互的网站.连接字符串大部分(如果不是全部)来自web.config文件.

任何帮助将是巨大的.

谢谢进阶

Tim



If I just have the one ''\'' in the Data Source I get a syntax error, and if I have two ''\'' i get that program couldn''t find the instance.

The SQL server is configured correctly because we have a web site for the Help Desk to interface with the system. The connection string is mostly if not all from the web.config file.

Any assistance would be great.

Thanks in advanced

Tim

推荐答案

如果LANSWEEPER是服务器名称,那么您将需要像这样更新连接字符串:
If LANSWEEPER is a server name, then you will need to update your connection string like this:
Dim ConnectionString As String = "Data Source=\\\\LANSWEEPER\\SQLEXPRESS;Initial Catalog=lansweeperdb;User ID=sa;Password=MYsaPASSWORD;Connect Timeout=30"


我发现了问题所在.

这是因为我的数据库驻留在Express版本上,并且数据库大小超出文件大小限制4096 mb的0.18 mb.

因此,每次它尝试连接时,它都超过了文件大小的限制,SQL Express会将斧头压在我的连接上.

这很奇怪,因为我可以通过Toad登录.

无论如何,谢谢您的帮助.
I figured out the problem.

It was because my database resided on a Express edition and the database size is 0.18 mb of exceeding its file size limit of the 4096 mb.

So every time it tried to connect it exceed the file size limit and SQL Express would put the ax down on my connection.

Which is weird because I can log in through Toad.

Anyways, thanks for the help marcus.


这篇关于VB.Net VS 2010 SQL连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆