473,473 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Question on Data Access Application Block (DAAB)

Hi,

I have Question on DAAB.
I created 2 connection parameters one for Development box and another For
Test box, when I tried to access them using this piece of code, I get an
error

Here's what I did:
in the dataConfiguration.config:
<instances>
<instance name="Database Instance" type="Sql Server"
connectionString="Development" />
<instance name="Database Instance" type="Sql Server"
connectionString="Test" />
</instances>
<connectionStrings>
<connectionString name="Development">
<parameters>
---Some parameters here---
</parameters>
</connectionString>
<connectionString name="Test">
<parameters>
---Some parameters here---
</parameters>
</connectionString>
</connectionStrings>

In the Code:
I tried this
Dim ds As DataSet =
DatabaseFactory.CreateDatabase("Development").Exec uteDataSet(CommandType.Text,
_
"SELECT * FROM Categories ORDER BY CategoryName")

It gave me an error....
but when I changed it to this
Dim ds As DataSet =
DatabaseFactory.CreateDatabase().ExecuteDataSet(Co mmandType.Text, _
"SELECT * FROM Categories ORDER BY CategoryName")

it worked fine...
I understand it takes the default value from the dataConfiguration.config
file but everytime i switch from Dev to Test i have to change the
connectionString in instance name to point appropriately...

can you please tell me how to avoid this?
Thanks,
Stephen
Jul 24 '06 #1
2 1116
Well sir i m afraid you have to do this way simply because u ve inserted 2
keys with similar name so .NET will return the fiirst value it will find.
Other wise you have to provide name. Otherwise bydefault it will always take
the Dev string.

"stephen" wrote:
Hi,

I have Question on DAAB.
I created 2 connection parameters one for Development box and another For
Test box, when I tried to access them using this piece of code, I get an
error

Here's what I did:
in the dataConfiguration.config:
<instances>
<instance name="Database Instance" type="Sql Server"
connectionString="Development" />
<instance name="Database Instance" type="Sql Server"
connectionString="Test" />
</instances>
<connectionStrings>
<connectionString name="Development">
<parameters>
---Some parameters here---
</parameters>
</connectionString>
<connectionString name="Test">
<parameters>
---Some parameters here---
</parameters>
</connectionString>
</connectionStrings>

In the Code:
I tried this
Dim ds As DataSet =
DatabaseFactory.CreateDatabase("Development").Exec uteDataSet(CommandType.Text,
_
"SELECT * FROM Categories ORDER BY CategoryName")

It gave me an error....
but when I changed it to this
Dim ds As DataSet =
DatabaseFactory.CreateDatabase().ExecuteDataSet(Co mmandType.Text, _
"SELECT * FROM Categories ORDER BY CategoryName")

it worked fine...
I understand it takes the default value from the dataConfiguration.config
file but everytime i switch from Dev to Test i have to change the
connectionString in instance name to point appropriately...

can you please tell me how to avoid this?
Thanks,
Stephen
Jul 26 '06 #2
I'm replying to this post because its the most recent applicable area I
can find. I searched forever to find vb.net style code to hit a stored
proc using the DAAB for the sole purpose of looping thru it. Here is
what worked for me. I'm sure something is screwed up with it, but it
worked. So feel free to comment on how to release/dispose, do
differently, etc.:
------
Dim db As Database = DatabaseFactory.CreateDatabase("DATABASE
CONNECTION NAME STRING DEFINED IN WEB.CONFIG UNDER
<connectionStrings>")

Dim dr As SqlDataReader = db.ExecuteReader("PROC NAME")

While dr.Read
Response.Write(dr.GetString(1))
End While

dr.Close()
dr = Nothing

-------------

Maybe my Google searching capabilities have turned into shite, but I
could not find simple examples of this anywhere.

Bob.

Aug 5 '06 #3

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

Similar topics

5
by: José Joye | last post by:
Hi, Does anyone know if there is a planned support for MS Access in the MS DAAB? Thanks, José
7
by: scott289 | last post by:
I have successfully downloaded the Enterprise Library and the data access block (C#). I am able to compile and run the quickstart application. So I would like to try the DAB in a new project....
1
by: Özgür Aytekin | last post by:
Hello NG Is DAAB 3.1 the offical replacement of Microsoft Data Access Application Block 2.0? DAAB 3.1 download:...
5
by: Edward W. | last post by:
I was looking at the data access application block version 2 and considering what I had read about connection pooling in that to use connection pooling successfully, you should close your...
0
by: Elias | last post by:
Hi, I recently started playing around with the DAAB from Microsoft as part of the Enterprise Library...
3
by: Rachel | last post by:
Hi, I am using the data access application block successfully in our development environment, however when I deploy to our testing server as Private Assemblies I keep getting the following ...
0
by: Mythran | last post by:
I'm not sure how the DAAB for .Net 2.0 works, but the v1.1 DAAB throws SqlException's. Why? When a database raises an error, the DAAB should wrap the error with it's own custom dbms-independant...
3
by: craig | last post by:
I was just wondering if anyone else may have incorporated the original Microsoft Exception Management Application Block (EMAB) or Data Access Application Block (DAAB) into one of their applications...
2
by: =?Utf-8?B?TWlrZVo=?= | last post by:
I created a function to use DAAB return a datareader. The connection must keep opening when I consume the datareader. 1. I tested the function, it works. Even I use the datareader after 10...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.