Avatar of Sheldon Livingston
Sheldon Livingston
Flag for United States of America asked on

Need connection string for SQL 2008.

Hello all,

I need a connection string from c# to SQL server 2008.

The code below doesn't work.

Provider = SQLOLEDB; Server = ServerName; User id = UserName; Password = ThePassword; Database = TheDB

I get Invalid connection string attribute

I'm using ADODB.
Microsoft SQL ServerC#SQL

Avatar of undefined
Last Comment
Sam Jacobs

8/22/2022 - Mon
Bill Prew

I forget exactly what 2008 needed, but try this newer syntax:

"Provider=SQLOLEDB;Data Source=serverName;Initial Catalog=databaseName;User ID=MyUserID;Password=MyPassword;"

Open in new window


»bp
Sheldon Livingston

ASKER
Bill... I get the error that my server doesn't exist.
Bill Prew

Are you able to connect to that server any other way from the client, via SQLCMD or SSMS, etc?


»bp
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Sheldon Livingston

ASKER
Via RDP.
Bill Prew

Well, that's connecting to it as a RDP server, not a SQL Server database server.  It sounds like SQL Server may not be running there currently.


»bp
kaufmed

www.connectionstrings.com - The connection string bible as it were.

Specifically:  https://www.connectionstrings.com/sql-server-2008/
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Qlemo

Make sure to not use spaces before =, and better not to do that after either.
Provider= SQLOLEDB; Server= ServerName; User id= UserName; Password= ThePassword; Database=TheDB

Open in new window

should work - if you made sure you can connect to MSSQL from remote at all.
Sheldon Livingston

ASKER
This is a functioning SQL Server with web pages on it.
Bill Prew

Just to be clear, web pages would come off of an IIS web server, not a SQL Server database server.

Both could be active on the same server, but just to clarify...


»bp
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Sheldon Livingston

ASKER
Right... I have a webserver that has SQL on it.  What I'm trying to do is write a piece of software that monitors and email address.  Once it sees an email it will parse it and update some fields in a SQL database.

Currently the program can pull the email and parse it.

What I thought would be a no brainer (connecting to SQL) is the most difficult part.
Qlemo

Your software find runs on the server, or remote?
Sheldon Livingston

ASKER
Qlemo... I don't know what "Your software find on the server, or remote?" means.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Sam Jacobs

Sheldon ... can you create a SQL Server ODBC connection to the SQL Server and see your databases in the wizard ?
ODBC-Connection.jpg
Sheldon Livingston

ASKER
Sam... I cannot.  Doesn't see the server:
ODBC
Sam Jacobs

Ok ... that means that SQL is not listening for connections (or cannot resolve the name).
Can you connect via IP address?
Can you TELNET <ip address> 1433  (assuming you're using the default SQL port)?
If not, you might want to start by rebooting the server (if you haven't already).
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Sheldon Livingston

ASKER
I can RDP via the IP address... the local IP address (non-routed 10.x)
I'll need to install Telnet later.
Server is working fine and not needing a reboot.  It is a webserver and is serving up pages fine.
Sam Jacobs

As Bill mentioned earlier, IIS and SQL Server are different services (IIS listens on 800/443, and SQL listens on 1433), so just because one is working, doesn't mean that the other is.
If you RDP to the server, can you connect to the databases with SQL Server Management Studio?
Sheldon Livingston

ASKER
Yes I can connect to the server via RDP and the studio.  That is how I maintain it.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
Sam Jacobs

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Sheldon Livingston

ASKER
So... I shut down the FW and could connect.  I then turned on the FW and made an inbound rule for 1433 and it worked.

Thank you Sam!
Sam Jacobs

Cool ... I hate firewalls, but unfortunately, they are a necessary evil! :)
Sheldon Livingston

ASKER
Thanks again Sam!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Bill Prew

Glad you got that resolved Sheldon, well done Sam.


»bp
Sam Jacobs

@Sheldon ... you are most welcome.

@Bill ... Thanks.