View Full Version : C# access conection error
villagecirc
11-17-2003, 11:01 AM
My code is error free but when I go to veiw it in the browser I get the following error does anyone reconize this error message[V]
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.OleDb.OleDbConnection.Open() +203
Test.Test.ReturnDataset(String cmdText) in c:\documents and settings\smpaulson\vswebcache\www.villagecircle.ne t\test\test.aspx.cs:39
Test.Test.Page_Load(Object sender, EventArgs e) in c:\documents and settings\smpaulson\vswebcache\www.villagecircle.ne t\test\test.aspx.cs:28
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
I am at a loss and just when I thought I had it going I seem even further than I started if anyone has any idea what I have done wrong or any other suggestions in the matter it would be greatly apreciated....[V]
Matthew H. Paulson
matt@villagecircle.net
http://www.villagecircle.net
villagecirc
11-18-2003, 09:15 AM
conection string within web.config within same aplication is....
<configuration>
<appSettings>
<!-- add this kind of key -->
<add key="myConn" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\web\villagecirc\htdocs\_database\bt.mdb"/>
</appSettings>
<system.web>
code in its entirety....
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Web.Configuration;
namespace Test
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class Test : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
DataSet MYDS = ReturnDataset("SELECT * FROM Events");
}
public static DataSet ReturnDataset(string cmdText)
{
OleDbConnection conn = new OleDbConnection ();
{
conn.ConnectionString = System.Configuration.ConfigurationSettings.AppSett ings["ConnectionString"];
conn.Open();
OleDbDataAdapter da = new OleDbDataAdapter ();
OleDbCommand commSQL;
commSQL = new OleDbCommand();
commSQL.Connection = conn;
commSQL.CommandType= CommandType.StoredProcedure;
commSQL.CommandText=cmdText;
da.SelectCommand = commSQL ;
DataSet ds = new DataSet();
da.Fill (ds) ;
conn.Close() ;
return ds;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
Please note the code is error free in the debugger but gives the previous posted generic error message when opened in a browser
I used ftp to place the database within the database folder listed within the web.config file [?]
Matthew H. Paulson
matt@villagecircle.net
http://www.villagecircle.net
bruce
11-18-2003, 11:27 AM
Please post your code.
This error is too general for people to help
[b]quote:Originally posted by villagecirc
My code is error free but when I go to veiw it in the browser I get the following error does anyone reconize this error message[V]
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.OleDb.OleDbConnection.Open() +203
Test.Test.ReturnDataset(String cmdText) in c:\documents and settings\smpaulson\vswebcache\www.villagecircle.ne t\test\test.aspx.cs:39
Test.Test.Page_Load(Object sender, EventArgs e) in c:\documents and settings\smpaulson\vswebcache\www.villagecircle.ne t\test\test.aspx.cs:28
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
I am at a loss and just when I thought I had it going I seem even further than I started if anyone has any idea what I have done wrong or any other suggestions in the matter it would be greatly apreciated....[V]
Matthew H. Paulson
matt@villagecircle.net
http://www.villagecircle.net
</blockquote id="quote"></font id="quote">
bebemau
11-19-2003, 03:08 AM
Your key name is myConn, not ConnectionString
bruce
11-20-2003, 06:28 AM
I think the path should look like
E:\web\villagecirc\htdocs\database\T.mdb
instead of
E:/web/villagecirc/htdocs/_database/BT.mdb
[b]quote:Originally posted by villagecirc
thank you that was it now I am getting a more specific error
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The ':' character, hexadecimal value 0x3A, cannot be included in a name. Line 5, position 85.
Source Error:
Line 3: <appSettings>
Line 4: <!-- add this kind of key -->
Line 5: <add key="ConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="E:/web/villagecirc/htdocs/_database/BT.mdb" />
Line 6: </appSettings>
Line 7: <system.web>
Source File: E:\web\villagecirc\htdocs\Test\web.config Line: 5
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.903
Matthew H. Paulson
matt@villagecircle.net
http://www.villagecircle.net
</blockquote id="quote"></font id="quote">
villagecirc
11-20-2003, 08:04 AM
thank you that was it now I am getting a more specific error
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The ':' character, hexadecimal value 0x3A, cannot be included in a name. Line 5, position 85.
Source Error:
Line 3: <appSettings>
Line 4: <!-- add this kind of key -->
Line 5: <add key="ConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="E:/web/villagecirc/htdocs/_database/BT.mdb" />
Line 6: </appSettings>
Line 7: <system.web>
Source File: E:\web\villagecirc\htdocs\Test\web.config Line: 5
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.903
Matthew H. Paulson
matt@villagecircle.net
http://www.villagecircle.net
villagecirc
11-20-2003, 08:22 AM
for some odd reason I am getting an error on the closing tag
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 6, position 5.
Source Error:
Line 4: <!-- add this kind of key -->
Line 5: <add key="ConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source='e:\web\villagecirc\htdocs\_database\BT.mdb '/>
Line 6: </appSettings>
Line 7: <system.web>
Line 8:
Source File: E:\web\villagecirc\htdocs\Test\web.config Line: 6
I though I was home free after I got the dang connection string to work does anyone know why I would get an error with this closing tag[?]
Matthew H. Paulson
matt@villagecircle.net
http://www.villagecircle.net
steurm
11-20-2003, 11:20 AM
[b]quote:Originally posted by villagecirc
for some odd reason I am getting an error on the closing tag
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 6, position 5.
Source Error:
Line 4: <!-- add this kind of key -->
Line 5: <add key="ConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source='e:\web\villagecirc\htdocs\_database\BT.mdb '/>
Line 6: </appSettings>
Line 7: <system.web>
Line 8:
Source File: E:\web\villagecirc\htdocs\Test\web.config Line: 6
I though I was home free after I got the dang connection string to work does anyone know why I would get an error with this closing tag[?]
Matthew H. Paulson
matt@villagecircle.net
http://www.villagecircle.net
</blockquote id="quote"></font id="quote">
not very odd ... you start the 'value' in your connectionstring with a double quote, but you are not closing that again ...
change it to
[quote]
addkey="ConnectionString"value="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=e:\web \villagecirc\htdocs\_database\BT.mdb"/></CODE>
and you won't have any problems any more (neither do you need to enclose the source within single quotes).
Success !
--
Steurm
www.steurm.net/steurm
steurm
11-21-2003, 01:26 AM
Your welcome ... if everybody would only read forums, they wouldn't last long I think
--
Steurm
www.steurm.net/steurm
villagecirc
11-21-2003, 11:23 AM
[:)]I was finally able to get the dataset bound to a datagrid and I wanted to thank everyone for takeing the time to respond to my error messages. The first time doing something is always like pulling teeth to me but preseverence is the ...
I had one more question are we able to update the data base using update commands delete commands and insert commands and so on?????[^]
Matthew H. Paulson
matt@villagecircle.net
http://www.villagecircle.net
bruce
11-21-2003, 11:42 AM
Matthew,
Yes. You should be able to do that.
[b]quote:Originally posted by villagecirc
[:)]I was finally able to get the dataset bound to a datagrid and I wanted to thank everyone for takeing the time to respond to my error messages. The first time doing something is always like pulling teeth to me but preseverence is the ...
I had one more question are we able to update the data base using update commands delete commands and insert commands and so on?????[^]
Matthew H. Paulson
matt@villagecircle.net
http://www.villagecircle.net
</blockquote id="quote"></font id="quote">
vBulletin® ©Jelsoft Enterprises Ltd.