2011-07-05 57 views
0

最近几个月稳定工作的代码现在已停止工作。我们推出的任何产品都没有升级(Windows或其他)。无法通过Excel连接到SQL Server 2008 VB7

下面的代码将数据推到一个SQL Server 2008数据库:

Dim db As New ADODB.Connection 
''#Other data manipulation not shown 
With db 
    ''#On Error Resume Next ''# With or without this line I still get no indication of the error 
    .ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security  Info=True;Data Source=myDB;" & _ 
      "Use Procedure for Prepare=1;Auto Translate=True; Packet Size=4096; Use Encryption for Data=True;" & _ 
      "Tag with column collation when possible=false;Initial Catalog=SFM_market" 
    .Open 
    .Execute query 
    .Close 
End With 

的数据库状态字段读0​​次。这是我的理解,它应该读1当它已成功连接。

我最近还重新考虑将ADODB.Command与ADODB.Connection一起使用,但最终结果是相同的。状态字段保持为0.我没有遇到任何错误,数据根本不会进入数据库,因为没有建立连接。

任何想法,为什么这可能是?

+1

您将不会收到错误消息,其中包含错误继续下一步潜伏 - 请先尝试删除,以便您可以看到发生了什么问题。 – gibeath

+0

感谢您指出这一点,遗憾的是它并没有提供任何进一步的洞察力。 – BOMEz

+0

在那之后你有没有收到任何类型的错误信息? – gibeath

回答

0

只是为了完整性,答案是简单的重新启动。我连接的方式没有错。

0

我能想出的最好的建议是检查你的连接字符串。您有很多选择,如果其中任何一个都是错误的,连接将失败。尝试将其降低到完成连接所需的最低限度的信息,并从那里建立起来。