Saturday, February 11, 2012

"Data Source=%?SERVER%"... ?

Hi all...

I have a data source string being passed to a SqlConnection object in the format "Data Source=%?SERVER%[...]". Now, to me this kind of looks like an environment variable query, but I'm not sure (and I can't find any system environment variables with that name on the server. Can anyone tell me, specifically, what the "?" is for?

This project uses VS2005, C# 2.0

Thanks in advance.

It looks to me like it is meant to be a value that is prompted for. Where are you getting the connection string from?

|||

There's no prompting going on - that's just the value in the string. Here's a sample:

1string strCon ="Data Source=%?SERVER%;Initial Catalog=MyDatabase;Integrated Security=False;Persist Security Info=True;User ID=sa;Password=%?SAPWD%;Encrypt=False";2SqlConnection con =new SqlConnection(strCon);
Thanks again.|||Data Source is the name of your sqlserver instance. like connectionString="Data Source= MSHOME\SQLEXPRESS;Initial Catalog=....|||

Well if you don't know of any reason why that is there and you know the connection information put the connection string in the web.config and call it a day. :)

|||

Guess that's what I'm going to have to go with (web.config) :P

Was just hoping somebody knew if there was something along the lines of a search-&-replace-before-compile feature in VS2005...

Thanks

No comments:

Post a Comment