Showing posts with label retrived. Show all posts
Showing posts with label retrived. Show all posts

Friday, February 10, 2012

Connect to SQL Server 2005 Problem

Hi all,

I have created an Outlook Add-in using VS2005, which basically populates a custom WinForm with some data retrived from the backend SQL Server 2005 database.

The SQL Server is installed on the same computer as the development environment (VS 2005).

The add-in code compiles OK and I have created a setup package for this app, which installs the required files with no problem. The package has been tested working on the development machine. But as soon as I install it on another computer (installation was no problem, and outlook launched the add-in as expected) and click on the add-in button I made on the menu bar, the add-in hangs up.

I have checked the tables on the sql server and found that no operations was performed whatsoever. Suspecting there are errors connecting to the server, I also threw in some Try - Catch pairs to catch the exceptions, but still nothing pops up as if the app couldn't even start while it runs just fine on the development machine.

Below is how I connect to the SQL Server 2005 in my code (VB)

Dim cn As ADODB.Connection = New Connection
Dim rst As Recordset, query As String
cn.ConnectionString = "Provider=SQLNCLI;Server=Development;Database=Project1;Trusted_Connection=yes;"
cn.Open()

query = "SELECT * FROM Sample_Tab;"
''' Do something with the connection
Try
rst = cn.Execute(query)
Catch ex As Exception
MsgBox("ADODB Error: " & ex.ToString)
Exit Sub
End Try

cn.Close()

Any help will be greatly appreciated.

-rahx

Did you enable NP and/or TCP on your SQL Server? You need make sure that your sql can accept remote connection. Do you have firewall? Please follow the instruction and give us me info http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=362498&SiteID=1

|||Problem solved - my mistake. I used sql native client in my code but forgot to include a sql native client msi in the installation package.

After installing the native client on the test computer, the connection was established successfully.