Wednesday, March 7, 2012

how initialize a connection string in .Net

i am using a control that i downloaded from the control gallery It has a line for a connection string.

which i put on in there:

data source=server;initial catalog=database;user id=blahblah;password=557896
and i get an error:

Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: The ConnectionString property has not been initialized.]
System.Data.SqlClient.SqlConnection.Open() +433
Microsoft.Vote.VoteButtonClick(Object sender, EventArgs e) +289
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277

How would i initialize the connection string.

any help would be appreciated

aluckeHi,
normally we would have initialized the connection by doing this

dim conn as new sqlconnection("data source=server;initial catalog=database;user id=blahblah;password=557896")

if you still experience error can you print out your codes too?

No comments:

Post a Comment