Thursday, March 22, 2012

Can not connect to database

I am new to windows apps in .net 2.0. I am trying to create a windows service that will connect to a database and email info out to people that have had status changes.

Right now, I can not connect to the database. Here is the connection string:

Private cnnAsNew SqlClient.SqlConnection("Data Source=IPAddress;Initial Catalog=TheServer;Persist Security Info=True;User ID=userid;Password=password provider=SQLOLEDB.1;connect timeout=3600")

This is how I am trying to connect:

cnn.Open()

myCMD.CommandTimeout = 0

dr = myCMD.ExecuteReader

I keep getting an error message that I can not be logged on. I know that the credentials are correct because I use them for the web app. Something has to be wrong with my connection string, but what?

Thanks,

enak

Seehttp://www.connectionstrings.com for examples of properly formatted connection strings. You do not need the "provider" parameter, and if you did it should be separated from the other parameters by a semicolon (not a space).

If you are still having trouble you should post the exact error message (or better yet, first search the forums or Google for that error message).|||Took out the provider and it worked. Thanks.sql

No comments:

Post a Comment