.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

connection property has not been initialized

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :Windows Application

hi all

i am developing winforms application in c#

My ConnectionString in app.config is 


<add name="MyConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\UttamPayDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />

View Complete Post

More Related Resource Links

ExecuteReader problem in web form: Connection-property not initialized


I changed my data source from an access-db to a sql-server, now i still have to fix some problems Undecided

When I want to load a value from a sql-database into my web form (to display a default value), I get an ExecuteReader error ("Connection-property not initialized").

I dont know where to set the connection property in my code.

Dim con As New System.Data.SqlClient.SqlConnection()
Dim myCommand As New System.Data.SqlClient.SqlCommand
Dim SqlCon As String = "Data Source=blablabla\SQLEXPRESS;Initial Catalog=Bill;Persist Security Info=True;User ID=xxx;Password=password"
con.ConnectionString = SqlCon
Dim reader As System.Data.SqlClient.SqlDataReader = myCommand.ExecuteReader() 

The error occurs in the last line. Do I have to set the connection property in the SqlCon string?

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.

The property or field has not been initialized. It has not been requested or the request has not bee


Hello, when a try execute this method, i receve always this error message.



private void button1_Click(objec

How set connection Integrated Security property


Does anyone have a handy snippet of code in C# or VB.net to find and set the "Integrated Security" property of a connection?

I used to do this stuff in DTS, but ... that was a long time ago!




RowDelimiter property for FlatFile Connection not mapping to a variable correctly


I've ran into the following problem:

I have flat files originating from different systems (MS-DOS, AIX and Windows). Therefore the files have different line endings (CR, LF and CRLF respectively).
I'm using a Script Task inside a ForEach enumerator to find a row delimiter for each file and put the value into a string variable. Then I use Data Flow task to import the data from the flat file into the database. The script task runs fine and sets the variable value to {CR}, {LF} or {CR}{LF} for each file. Columns are delimited with "!" character.

When I map the RowDelimiter property of the FlatFile Connection Manager to the variable using Expressions the subsequent Data Flow task doesn't import the data correctly. I've tried using Format=Delimited and Format=RaggedRight (I removed the last column delimiter), both ways fail to import the data correctly.
Although the mapping of the ConnectionString property to a variable (ForEach populates this variable with the path of the file) works perfectly.

I've even tried setting up all combinations of quotes and brackets on the string variable value ("{CR}", '{CR}', {CR}, CR) ...

The platform  I'm working on is Windows Server 2008 x64 and SQL Server 2008 x64 ...

My current workaround idea is to write a Script Task that would replace all

Check the if SSAS Roles property is used in excel connection string before returning the values



We are using Excel 2007 to connect to SSAS cubes. We have many roles for a user and all having different permission including different VISUAL TOTAL setting. We want to restrict the user so that he cannot see anything if he is not using the ROLES property in the excel connection string.

At the run time I want to know if the user who is using excel has used ROLES property or not.

Any help will be appreciated

Mr myName

SQL Connection String

We can learn or know how can we connect the database from our .net. This will help for freshers or .NET beginners!

WPF / Silverlight tutorial: Visibility property and binding

Visibility property is a very powerful and yet often overlooked property available in both WPF and Silverlight. It enables you to set Visibility of certain UIElement objects to different states like: Visible, Collapsed and Hidden (not supported by Silverlight). This tutorial shows you how to use it and how to bind to Visibility property

Get pixel format, raw format, property id list and property items image in VB.net - C#.net.

n this simple article you will learn that how we can get pixel format, raw format, property id list and property items image in VB and C#.net.

Get Pixel Format:

Image consists of pixels to get the format of the pixel we have a property named pixel format. This property returns an enumeration of pixel format. This enumeration tells the pixel format.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:

Jscript error: Object does not support property or method


 Hi, i have little knowledge on javascript but i need to use this code get from somewhere for a jquery to work.

I face this "Jscript runtime error: Object does not support property or method" whenever im trying to run this page.

In my experience, im get this error msg 9 out of 10 times i use javascript in my system.

Im using Microsoft Visual web developer 2008, i wonder if this is related to my problem, i not sure there is anything i need to add as reference or update anything.

But anyway, in short, i just couldn't use javascript code when using this development tool because of this sort of error.

Anyway, it happen that last time i tried use the same type of jquery code in another project and it seems to work well without an error.

But now when im try to use it again in this recent project i created, it come out with this error and i have no idea how to solve it even look through google and this forum.

It doesn't really seems like its the code problem itself although im not sure, because any javascript code just couldn't work.

So below is my code that i need to use.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript" src=&quo

connection string question from a newbie


when publishing  in the webmatrix dialogue it asks for "destination connection string" for my "database.mdf"

I was not sure what it was so I pasted this from my web.config file :

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;User Instance=True

it all published ok, but wont run, so I guess it has somthing to do with this connection string or some kind of configuration issue.

My question is this, What should go in the field for "Destination connection string"

localhost is not set up to establish a connection on port 51624 with this computer


I'm trying to run asp.net locally, but getting the error

localhost is not set up to establish a connection on port 51624 with this computer

How can I fix it?

connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly.


I dont have the SQL EXPRESS installed instead I have SQL Standard Edition.

 I have two SQL Server instances installed.

 1- UserLT (this is sql 2000)
2- UserLT\SQL2005 (this is SQL 2005 named instance)

But when i try to add a database to my VS website project I get the following error:

Connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly. please verify the installation of the component or download from the URL: go.microsoft.com/fwlink/?linkId=4925

I went in Tools>Opetions>DataBase tools>Data Connection>Sql Server Instance Name (blank for default)

and changed the "SQLEXPRESS" to "USERLT\SQL2005".

But I still get the same error message. Any ideas how i can resolve this issue?

Unable to make connection to database?


Hy guys. I try to connect my database for so long so i wrote two type of codes. Let's discuse first on.

I have database called PhoneDirectory.

It have only one table named Residents.

I have button wiht ID="Button1".

I want when i click this button to see all of my residents. 

I want to see the result in DetailsView and to be able to edin, delete and add new resident.

First try with SqlDataSource so i wrote this:

<asp:SqlDataSource ID="Resident Details" runat="server" ProviderName="System.Data.SqlClient" ConnectionStrings="<%$ ConnectionStrings:ThisIsTheConnection%>" 
              SelectCommand = "SELECT * FROM Resident "

Need Oracle Data Provider .CS File for Oracle 10g Database connection !



I need a 'Wrapper.cs' file which takes care of the Database connection ( Oracle 10g) where

i can just call the method with my SQL Query


Gridview1.DataSource = SampleWrapper.ExecuteDatatable("THE SQL QUERY");


Plz Post the link if there is any open source !    

Is it possible to populate property choices from a database?


I'm creating my first server control, and have it working where I can set up an enum and the user can set a property's choices,  based off of that enum.  But I'd like it to pull records from a database and populate the list of choices for the property from a database.  This would allow me to add a new "Host System" to the database, and the other designers wouldn't have to get a new copy of the dll.



Custom Server Control Property not maintaining state


I have created a server control consisting of a TextArea and a div under it.  My goal is to create my own asp:TextArea type control.  the div is for a Character count of the text area and seems to work ok but i added a CharacterCountVisible property to the control that is always returning true.  See Proptery definition below


<Bindable(False), Category("Appearance"), DefaultValue("True"), Localizable(True)> Property CharacterCountVisible() As Boolean
        Return _CountBoxVisible
    End Get
    Set(ByVal value As Boolean)
        _CountBoxVisible = value
    End Set
End Property

Note the _CountBoxVisible variable is define inside the class as :

Dim _CountBoxVisible as Boolean = True

What I am trying to do is give the user/coder the option to show/utilize the char count feature.  Can make it disappear with textarea1.CharacterCountVisible = False but setting it to true will not make it display.


What am i missing





ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend