473,395 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Enterprise Library error

Hello Everyone,

I downloaded enterprise library 2.0 , 2006 today . I followed all the
instructions that were given in the documentation.
I tried to follow everything that was mentioned in QuickStart samples. I
made a small web application that did everything that Quick start sample was
doing and I can successfully complie the code.
Below is my code. This is the exact code that is written in quick start
samples

Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "sp_getUserId";
DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

// Retrieve products from the specified category.
db.AddInParameter(dbCommand, "LogOn", DbType.Int32, "abcde2");

// DataSet that will hold the returned results
DataSet productsDataSet = null;

productsDataSet = db.ExecuteDataSet(dbCommand);
return productsDataSet;

The dll's I am including are
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;

other dll's that come automatically in the project are
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

I am getting a run time error on the first line of the code, Database db =
DatabaseFactory.CreateDatabase();
System.NullReferenceException {"Object reference not set to an instance of
an object."}

In the Quick startsamples they are not passing any parameter in
createDatabase().

Please let me know what am I doing wrong.

Thanks

Apr 18 '07 #1
4 7670
On 18 Apr, 03:14, Vinki <V...@discussions.microsoft.comwrote:
Hello Everyone,

I downloaded enterprise library 2.0 , 2006 today . I followed all the
instructions that were given in the documentation.
I tried to follow everything that was mentioned in QuickStart samples. I
made a small web application that did everything that Quick start sample was
doing and I can successfully complie the code.
Below is my code. This is the exact code that is written in quick start
samples

Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "sp_getUserId";
DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

// Retrieve products from the specified category.
db.AddInParameter(dbCommand, "LogOn", DbType.Int32, "abcde2");

// DataSet that will hold the returned results
DataSet productsDataSet = null;

productsDataSet = db.ExecuteDataSet(dbCommand);
return productsDataSet;

The dll's I am including are
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;

other dll's that come automatically in the project are
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

I am getting a run time error on the first line of the code, Database db =
DatabaseFactory.CreateDatabase();
System.NullReferenceException {"Object reference not set to an instance of
an object."}

In the Quick startsamples they are not passing any parameter in
createDatabase().

Please let me know what am I doing wrong.

Thanks
I imagine your config file has an error in it, it gets the connection
string from there. Compare yours with the quick start config.
Apr 18 '07 #2

Database db = DatabaseFactory.CreateDatabase();

this loads the "default instance". Look in web.config (or app.config)
There should be a one liner in the xml that has "default instance" or
something like that in there.
Database db = DatabaseFactory.CreateDatabase("myInstance");

this gets a specific instance. this should be the name of the connection
string.
The EntLib developers decided to piggy back off the new 2.0 connection
string stuff, instead of trying to reproduce (or replace it).

...

PS
productsDataSet = db.ExecuteDataSet(dbCommand);
return productsDataSet;
I actually prefer the .LoadDataSet method

//start code
db.LoadDataSet(dbCommand , productsDataSet , new string[]{
"table1", "table2" });
productsDataSet;

because I specifically name the tables. if you have a strong typed dataset,
then the tablenames have to match your strong tablenames of course.


"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:0E**********************************@microsof t.com...
Hello Everyone,

I downloaded enterprise library 2.0 , 2006 today . I followed all the
instructions that were given in the documentation.
I tried to follow everything that was mentioned in QuickStart samples. I
made a small web application that did everything that Quick start sample
was
doing and I can successfully complie the code.
Below is my code. This is the exact code that is written in quick start
samples

Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "sp_getUserId";
DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

// Retrieve products from the specified category.
db.AddInParameter(dbCommand, "LogOn", DbType.Int32, "abcde2");

// DataSet that will hold the returned results
DataSet productsDataSet = null;

productsDataSet = db.ExecuteDataSet(dbCommand);
return productsDataSet;

The dll's I am including are
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;

other dll's that come automatically in the project are
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

I am getting a run time error on the first line of the code, Database db =
DatabaseFactory.CreateDatabase();
System.NullReferenceException {"Object reference not set to an instance of
an object."}

In the Quick startsamples they are not passing any parameter in
createDatabase().

Please let me know what am I doing wrong.

Thanks

Apr 18 '07 #3
Thanks for the help. There was something wrong with my we.config file. now
that I successfully executed the code, I am getting a message or warning that
says "Coukd not find information for the element 'dataConfiguration'. I can
run my code though.

I have another question. In this case I can only use one connectionstring,
the default connection string , can I use multiple connection string in
web.config file if I am extracting data from different database.

Thanks again for all the help.

"sloan" wrote:
>
Database db = DatabaseFactory.CreateDatabase();

this loads the "default instance". Look in web.config (or app.config)
There should be a one liner in the xml that has "default instance" or
something like that in there.
Database db = DatabaseFactory.CreateDatabase("myInstance");

this gets a specific instance. this should be the name of the connection
string.
The EntLib developers decided to piggy back off the new 2.0 connection
string stuff, instead of trying to reproduce (or replace it).

...

PS
productsDataSet = db.ExecuteDataSet(dbCommand);
return productsDataSet;

I actually prefer the .LoadDataSet method

//start code
db.LoadDataSet(dbCommand , productsDataSet , new string[]{
"table1", "table2" });
productsDataSet;

because I specifically name the tables. if you have a strong typed dataset,
then the tablenames have to match your strong tablenames of course.


"Vinki" <Vi***@discussions.microsoft.comwrote in message
news:0E**********************************@microsof t.com...
Hello Everyone,

I downloaded enterprise library 2.0 , 2006 today . I followed all the
instructions that were given in the documentation.
I tried to follow everything that was mentioned in QuickStart samples. I
made a small web application that did everything that Quick start sample
was
doing and I can successfully complie the code.
Below is my code. This is the exact code that is written in quick start
samples

Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "sp_getUserId";
DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

// Retrieve products from the specified category.
db.AddInParameter(dbCommand, "LogOn", DbType.Int32, "abcde2");

// DataSet that will hold the returned results
DataSet productsDataSet = null;

productsDataSet = db.ExecuteDataSet(dbCommand);
return productsDataSet;

The dll's I am including are
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;

other dll's that come automatically in the project are
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

I am getting a run time error on the first line of the code, Database db =
DatabaseFactory.CreateDatabase();
System.NullReferenceException {"Object reference not set to an instance of
an object."}

In the Quick startsamples they are not passing any parameter in
createDatabase().

Please let me know what am I doing wrong.

Thanks


Apr 18 '07 #4
On 18 Apr, 22:14, Vinki <V...@discussions.microsoft.comwrote:
Thanks for the help. There was something wrong with my we.config file. now
that I successfully executed the code, I am getting a message or warning that
says "Coukd not find information for the element 'dataConfiguration'. I can
run my code though.

I have another question. In this case I can only use one connectionstring,
the default connection string , can I use multiple connection string in
web.config file if I am extracting data from different database.

Thanks again for all the help.

"sloan" wrote:
Database db = DatabaseFactory.CreateDatabase();
this loads the "default instance". Look in web.config (or app.config)
There should be a one liner in the xml that has "default instance" or
something like that in there.
Database db = DatabaseFactory.CreateDatabase("myInstance");
this gets a specific instance. this should be the name of the connection
string.
The EntLib developers decided to piggy back off the new 2.0 connection
string stuff, instead of trying to reproduce (or replace it).
...
PS
productsDataSet = db.ExecuteDataSet(dbCommand);
return productsDataSet;
I actually prefer the .LoadDataSet method
//start code
db.LoadDataSet(dbCommand , productsDataSet , new string[]{
"table1", "table2" });
productsDataSet;
because I specifically name the tables. if you have a strong typed dataset,
then the tablenames have to match your strong tablenames of course.
"Vinki" <V...@discussions.microsoft.comwrote in message
news:0E**********************************@microsof t.com...
Hello Everyone,
I downloaded enterprise library 2.0 , 2006 today . I followed all the
instructions that were given in the documentation.
I tried to follow everything that was mentioned in QuickStart samples. I
made a small web application that did everything that Quick start sample
was
doing and I can successfully complie the code.
Below is my code. This is the exact code that is written in quick start
samples
Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "sp_getUserId";
DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
// Retrieve products from the specified category.
db.AddInParameter(dbCommand, "LogOn", DbType.Int32, "abcde2");
// DataSet that will hold the returned results
DataSet productsDataSet = null;
productsDataSet = db.ExecuteDataSet(dbCommand);
return productsDataSet;
The dll's I am including are
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;
other dll's that come automatically in the project are
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
I am getting a run time error on the first line of the code, Database db =
DatabaseFactory.CreateDatabase();
System.NullReferenceException {"Object reference not set to an instance of
an object."}
In the Quick startsamples they are not passing any parameter in
createDatabase().
Please let me know what am I doing wrong.
Thanks- Hide quoted text -

- Show quoted text -
Certainly, I believe there's an overload which takes a string and that
allows you to have multiple entries in the config for different
databases.

Apr 19 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike Chamberlain | last post by:
Hi all. I'm trying to extend the Microsoft Enterprise Library Data Access Application Block (http://msdn.microsoft.com/library/en-us/dnpag2/html/daab.asp?frame=true) to work with a Borland...
3
by: veera sekhar kota | last post by:
hi, im seriously looking for right answer .... We are developing windows application in c#. I implemented DAAB(Data Access Application Block) 2.0 in our application. One of the senior asked...
0
by: veera sekhar kota | last post by:
im seriously looking for right answer .... We are developing windows application in c#. I implemented DAAB(Data Access Application Block) 2.0 in our application. One of the senior asked me to...
0
by: veera sekhar kota | last post by:
im seriously looking for right answer .... We are developing windows application in c#. I implemented DAAB(Data Access Application Block) 2.0 in our application. One of the senior asked me to...
0
by: Benny Ng | last post by:
Hi,All, When i deploy Enterprise library with my application ,i used XCOPY to deploy it into my test server. But when application runs, shown some error related registry. (But actually I haven't...
6
by: Jonathan Crawford | last post by:
Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +473 Hi I have installed the enterprise library on a development machine and created a project on our webserver. When...
1
by: David Herbst | last post by:
Enterprise Library Jan 2006 with Visual Studio 2005 on Windows 2000 Server sp4. My custom exception formatter fails with a "Unable to handle exception: 'LoggingExceptionHandler'." exception. ...
7
by: rockdale | last post by:
hi, I just downloaded Microsoft Enterprise Library Jan 2006 and try to integrate it into my asp.net application. As i am going to connect to mySQL database, I need to include the source code in my...
0
by: =?Utf-8?B?YW5rMmdv?= | last post by:
Hi, Thanks in advance for reading this. Not sure where to post this question, but I hope someone in here can help. Trying to write to Event Log in VS 2005 (.NET 2.0) using Enterprise Library...
1
by: GaryDean | last post by:
I now have installed (from the same install) Enterprise Library - January 2006 and Enterprise Library - June 2005. The install for these two was called Enterprise Library for .Net 2.0. (not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.