开发者

Can't connect to SQL Server 2008 through Excel VB7

Recently a bit of code which has worked solidly for a few months now has stopped working. There have been no upgrades (Windows or otherwise) done to any product that we have pushed out.

The code below pushes data into a SQL Server 2008 database:

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

The db State field reads 0. It is my understanding that it should read 1 when it has connected successfully.

I have also r开发者_JS百科ecently re factored to use ADODB.Command along with an ADODB.Connection, but the end result is the same. The state field remains at 0. I get no errors, the data simply does not go into the database since the connection is not made.

Any ideas on why this may be?


The best suggestion I can come up with is to check your connection string. You have a lot of options in there, and if any of them is wrong the connection will fail. Try to pare it down to the minimum required information to complete the connection and build up from there.


Just for completeness, the answer to this was a simple restart. There was nothing wrong with the way I connected.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜