Hello,
Im trying to connect to my new custom table in the mojo-database.
I have the following piece of code:
protected void Button1_Click(object sender, System.EventArgs e)
{
//Instantiate a connection.
string conn = string.Empty;
conn = ConfigurationManager.ConnectionStrings["MSSQLConnectionString"].ConnectionString;
System.Data.SqlClient.SqlConnection cnn1 = new System.Data.SqlClient.SqlConnection(conn);
cnn1.Open();
//Declare command to validate MemberID and password.
System.Data.SqlClient.SqlCommand cmd1 = new System.Data.SqlClient.SqlCommand();
cmd1.CommandType = System.Data.CommandType.StoredProcedure;
cmd1.CommandText = "GetUser";
cmd1.Connection = cnn1;
I get an error in the line: conn = ConfigurationManager.ConnectionStrings["MSSQLConnectionString"].ConnectionString;
It says: System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="App_Web_jnxwiwtm"
StackTrace:
at HelloMojoModule.ascx.Button1_Click(Object sender, EventArgs e) in c:\Projects\Mojoportal\Web\MyCustomModules\HelloMojoUserControl.ascx:line 50
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
Has it something to do with the connectionstring "MSSQLConnectionString" ??
This string stands in the user.config:
<add key="MSSQLConnectionString" value="server=****.*****.com;UID=*****;PWD=******;database=databasemojo" />
Please help! Thnx....