C# - Connection Property Hasn't Been Initialized While Running Application From IIS
Apr 4, 2011
I have one intranet based application.I have set windows authentication for it in Web.config as well as from IIS settings. While running my application through the source code, it works fine but while running from directly IIS then its giving me:
In some posts I have read on other forums, those with database connection problems (I am thinking about Access) sometimes get the error: 'Connection property has not been initialized' which might translate as 'you have not kick-started your connection'. One reason for that, according to a number of replies I have come across, is that 'you have not set the connection property of the command object' ('you have not told command how to connect').
So would something like this:
Code: Dim conn As New OleDbConnection Dim OleDbConnection As New OleDbConnection Dim cmd As New OleDbCommand conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|myDatabase.mdb;" conn.Open() cmd = New OleDbCommand("SELECT strName FROM school WHERE strName=@strName", conn) cmd.Parameters.AddWithValue("@strName", UserName.Text) cmd.Connection = conn cmd.ExecuteNonQuery() conn.Close()
a) initialise the connection property and b) set the connection property of the command object?
I am getting error ExecuteReader: Connection property has not been initialized. below is the code i am using.
SqlDataReader oReader = new SqlDataReader(); string sSQL = @" WITH TAB_CTE AS ( SELECT fbominum, fbompart, fparinum, flevel, fsono FROM sodbom WHERE fbompart= @fbompart and fsono = @fsono UNION ALL SELECT e.fbominum, e.fbompart, e.fparinum, e.flevel, e.fsono FROM sodbom e INNER JOIN TAB_CTE ecte ON ecte.fbominum = e.fparinum where e.fsono = @fsono ) SELECT * FROM TAB_CTE where fbompart <> @fbompart "; SqlCommand oCommand = new SqlCommand(sSQL, this._connection); oCommand.CommandType = System.Data.CommandType.Text; oCommand.Parameters.Add("@fbompart", ItemSODBOM.fbompart); oCommand.Parameters.Add("@fsono", ItemSODBOM.SONO); oReader = oCommand.ExecuteReader();//Here I am getting error
I am getting above mentioned error when I try to run the following code:
Private strConnString As String = ConfigurationManager.ConnectionStrings("conString").ConnectionString Private con As New SqlConnection(strConnString) Private pID As Integer 'FIRST SECTION Dim query As String = "query" Dim cmd As New SqlCommand(query)
[Code] .....
The error is coming from the second SQL cmd but if I comment out the first section; the second section runs fine.
I must have made another basic error but I just can't figure out what it is.
I am trying to setup my page with a drop down which value comes from one SQL query and item list comes from another SQL query to the same database...
what I want to do is:
read 1 line from bugs table. this line includes a projectid which will be the value of the drop down. I also read the projects table for active projects/id and load this as drop down items....
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString)) { conn.Open(); using (SqlCommand bug = new SqlCommand( "SELECT bugs.id, bugs.projectid, bugs.typeid, bugs.subtypeid, bugs.version, bugs.summary, " + "users.email AS creator, bugs.createddate, bugs.text, bugs.closeddate, bugs.history " + "FROM bugs INNER JOIN users ON bugs.creatorid = users.id WHERE (bugs.id = @idd)", conn)) { bug.Parameters.AddWithValue("idd", Request.QueryString["ID"]); try { SqlDataReader reader = bug.ExecuteReader(); if (reader.Read()) { String projectid = reader[1].ToString(); // read project name list... using(conn) using (SqlCommand projects = new SqlCommand("SELECT name, id FROM projects WHERE active=true")) try { SqlDataReader pr = projects.ExecuteReader(); // This line causes the exception... what am I doing wrong? while (pr.Read()) project.Items.Add(new ListItem(reader[0].ToString(), reader[1].ToString())); } catch { }
When I open an ASP.NET 3.5 project using VWD2010, I get a prompt error message,"The connection property in the web.config file is missing or incorrect.The connection string from the .dbml file has been used in its place."however, my project works successfully.
I have been looking through the event viewer on our server and can see quite a few people with this error but I can't replicate this myself but it is causing issues for people viewing our website is there anyway I can "initialize" Command Text property?
UPDATE
So I have this query
datelistquery = "SELECT DISTINCT property_id, ' - Sleeps ' + cast(number_slept as varchar) as combsleeps, number_slept FROM openquery ("+Application("hpbDsrc")+",'SELECT property_id, number_slept FROM web_details WHERE part_full_flag = ''F'' AND location = ''"&Session("TenChosenLocCode")&"'' AND property_id = ''"&Session("passedPropId")&"'' AND pets_yn like ''"&Session("TenPets")&"'' AND number_slept >= ''"&Session("TenAdults")&"'' AND year_week = ''"&Session("TenHolStDateHP1")&"'' AND on_hold = ''NO'' AND booked = ''NO'' ') ORDER BY number_slept, property_id"
So should I put at the start sqlCommand.CommandText(datelistquery) = "Select Distinct...."
public class DataClass{ public DataClass() { } /// <summary> /// return rows depend on position /// if you need 10th to 20th you need to pass start=10 and end=20 /// </summary> /// <param name="start">database start position of one row</param> /// <param name="next">database end position of one row</param> /// <returns></returns> public string GetAjaxContent(int start, int end) {
[code].....
When I'm trying to develop the unlimited scrolling in datalist i have an error like connection string not initialized I checked and rechecked.
I need to configure a property of a custom control I wrote, specifically before the control calls OnInit. If I assign it as part of the ASPX file, it naturally works, but if I instead move the assignment to different parts of the code-behind, it will throw an error for having an empty and invalid value. The following is what it looks like when functional in the ASPX page.
The property in question is FilterString, which is just a simple string. It should be noted as well that the FieldName property (inheritted from the control's base class "BaseFieldControl") would also throw an error if it is not initialized, but if I set FieldName in the code behind's OnInit method, it works correctly. FilterString is not so, it won't actually be assigned. So I know that some methods for certain properties will work for setting the property's value, but it won't always work. I tried placing it in OnPreInit as well, to no avail.
I am taking a dynamic assignment approach because the functionality of this page needs to be replicated for a number of different lists, and the FilterString and FieldName properties will differ in every case. Rather than write half a dozen mostly-identical aspx pages all with the same code behind but differing just in what those two properties are, I figured it would be wiser to use the page's query string and some derived parameters to set those properties dynamically. As such, what methods are available to accomplish this task?
I am executing a long-running Oracle stored procedure from .NET. The procedure takes about three hours to run. Ideally, the user should be able to kick off the procedure, close the browser, and come back later to check the results.
The problem is that the connection to the Oracle procedure is lost after exactly an hour. As you would expect, the Oracle procedre runs to completion if it is executed from SQL Plus. Strangely enough, it will also run to completion if I run in debug mode on my local machine (I start two threads, one of which executes the procedure. I set a breakpoint on the second thread).
Here is my connection string:
data source= (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=serverx)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=TestSID)))
i am develpping a alarm application when user minimized this it should be minimized appear near the system clock,local area connection icon(as hidden icon).
In an asp.net web form, I keep getting a connection reset error message. The page is doing a some long running processing (about 2-5 minutes).
I have no problem when the web request comes from the same machine as the web server. But when the request originates across the network, I get a connection reset error about 1:30 or 2 minutes into waiting for a response.
I have set the in web.config for this application and put the application it's own application pool.
What else can I try?
Edit
The purpose of this page is to accept input from the user, calculate something, and send the result back to them. The long running calculation isn't something I can offload until a later time.
My web app connects to my database server which is on my lan. It is usually very quick but once in a while the connection is extremely slow and has even causing errors by timing out. The server only has 1 gb of memory so I'm going to upgrade to at least 4 gb.
I have myConnectionString and it's working fine. In the Server Explorer, the Data Connection is even using myConnectionString to connect to the database. When I created my .dbml, it uses that same yConnectionString. However, now whenever I opened the .dbml file, pops up with the following message:The connection property in the web.config file is missing or incorrect.The connection string from the .dbml file has been used in its place.After this message is display and I clicked okay (because that's the only option), it creates myConnectionString2 in the web.config file with a different ID but no password provided. What is this all about? Why is it creating a second connection string with a different ID?
Im using two stored procedures to write and update values in a SQL DB. Im using the SQLDatasource update method. When I run the webpage on my development server everything runs fine. When I try and run the web page on my Live server I get the following error :System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding This always takes 30 seconds to fail - and looking at google it seems that this is a connection timeout error.In my web.config file I have updated the connectionstring line to include a timeout setting :
I am logged in as the administrator when I installed an application named pdflatex.exe on my server. This application works as a converter from LaTeX input file to Pdf file. I host an Asp.net MVC 3 application running under an Application Pool Identity with Load User Profile = True. The Asp.net MVC 3 code contains a code that executes pdflatex.exe using System.Diagnostic.Process instance as follows:
Process p = new Process(); p.EnableRaisingEvents = true; p.Exited += new EventHandler(p_Exited); p.StartInfo.Arguments = "-interaction=nonstopmode " + inputpath; p.StartInfo.WorkingDirectory = @"c:mydomain.comworking"; p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = "pdflatex.exe"; p.Start(); p.WaitForExit();
From the scenario above, the web application runs under a restricted acount but it executes an external application under a default account that I don't know. Can an application running under a less privileged account start a process executing another application under an administrative account?
I created a simple .NET 4.0 WebSite through VisualStudio 2010 using the Installed Template for ASP.NET Web Site.This brought me to "Choose Location" where I chose Local IIS, then Create New Web Application.This created the template app with all of the local files within IIS.This complies fine, but Im constantly getting the HTTP 403 Error "the website declined to show this webpage"I checked IIS properties for this and its set to 4.0 and the Directory Security has Anonymous Access enabled. Allow IIS to control password is also checked.I just installed VS 2010 on my new computer, and Im trying to get this configured so I can run 4.0 apps through IIS.
I am getting below error while running the application
Exception in MS Oracle DAAB Method - GetDataSet : Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "DABResource.resources" was correctly embedded or linked into assembly "DBServices" at compile time, or that all the satellite assemblies required are loadable and fully signed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Exception in MS Oracle DAAB Method - GetDataSet : Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "DABResource.resources" was correctly embedded or linked into assembly "DBServices" at compile time, or that all the satellite assemblies required are loadable and fully signed.
I have an application in asp.net.I configured it in IIS.When i running this application in IIS i getting an error;
Server "/" error: Resource Cannot be Found Error:404
Some of pages only produce this issues.Other forms are working perfectly.Without running application in IIS Its working perfectly. If any one can answer send the answer immediatly.