Monday, September 29, 2008

The ConnectionString property has not been initialized.

The ConnectionString property has not been initialized.



it is sooo easy. but you can waste a lot of time on this one.

Here is what was my problem:
1.) web.config:

< appSettings >
< add key="aaa" value="server=swoosh\sqlserver2k5;database=swdb;uid=sa;password=;" />
< / appSettings >

2.) accessing:
string strConnRSS = System.Configuration.ConfigurationManager.AppSettings["bbb"];

aaa <> bbb

Hope this'll help someone :)
don't look for anything too complicated :)

Friday, September 19, 2008

Monthname in C# (C Sharp)

I think there's no Monthname (like is asp for ex. - which is weird)

But this is easy:

DateTime swTest = new DateTime(2000, 11, 1);

Monday, September 1, 2008

SQL - add zeros to the left

Ever needed to add zeros to the left of your string?
For example: instead of "1", you need "0001" displayed.
All this from SQL ...

I think this is an easy way of doing that:

select replicate('0', 6-len(convert(varchar(50), 'aaa'))) + convert(varchar(50), 'aaa')

You need to change the '6' if longer, and 'aaa' is your string ...

what do you think?

Calling a server side from client's Javascript

Did you ever need something like calling a server side thing from client's? Javascript ... ?

I think this is an easy way of doing that:

Response.Write ( " < script language="javascript"> function SetPmoR_Id() { document.all('" + lkbPmoRepAdd.ClientID + "').click(); } < / script>")


ClientScript.RegisterClientScriptBlock(this.GetType(), "somethn", " < script type='text/javascript'> function whatdoyouwannacalit() { try {document.all('" + yourlinkbutton.ClientID + "').click();} catch(e){} } < / script>");

what do you think?

you think there's an easier way? comment!