Error while using readymade DAL component

Posted by Thiru under ASP.NET on 10/9/2011 | Points: 10 | Views : 1531 | Status : [Member] | Replies : 7
Hi,

I am getting the following error while using readymade DAL component:
Please help me to solve this error.

Please refer the attached file to get the files i used (aspx, aspx.vb, web.cofig)

An error occurred creating the configuration section handler for dataConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (D:\ASPNETStudy\web.config line 12)


Actual code is:

Imports System
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.Data.Sql
Partial Class UsingDALcomponent
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim objdb As Database = DatabaseFactory.CreateDatabase()
GridView1.DataSource = objdb.ExecuteDataSet("SPselectmem")
GridView1.DataBind()
End Sub
End Class




ASPX Page:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="UsingDALcomponent.aspx.vb" Inherits="UsingDALcomponent" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

<b>Using DAL Component:<br />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</b>

</div>
</form>
</body>
</html>


PLEASE REF. ATTACHED ZIP FILE TO SEE THE ASPX, ASPX.VB, WEB.COFIG FILES




Responses

Posted by: Ndebata on: 10/9/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Thiru,

You DAL component is using Microsoft enterprise library, You have to add reference to these two dlls in your project along with the same connection string name used in your DAL.

Microsoft.Practices.EnterpriseLibrary.Data.dll
Microsoft.Practices.EnterpriseLibrary.Common.dll


Thanks,
Debata

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thiru on: 10/10/2011 [Member] Starter | Points: 25

Up
0
Down
Thanks for your reply Debata,
But its already added.

As in my bin:
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll
Microsoft.Practices.ObjectBuilder2.dll
Microsoft.Practices.Unity.dll
MySql.Data.dll

Note: i have used MySQL DB in one webform -- so, i added reference of MySql.Data.dll
But i am getting error while using DAL component for MS SQL data in another form -- which i have mentioned in my previous post along with attachments.

Expecting your valuable reply in this regard.

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 10/10/2011 [Member] Starter | Points: 25

Up
0
Down
It should work
Check the connection string name is same in both web.config and that of in DAL layer
Try to add your DAL project to your Webform solution and see you could debug.

Thanks,
Debata

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thiru on: 10/11/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Debata,
I checked in web.config and i used the same connection string and re-write the code as normal
connection as: conn.string, command, adapter... its working fine.

but not working when i use DAL component.

You suggest me to check connection string in both - right.
i can able to check in web.config -- BUT HOW TO CHECK CONNECTION STRING IN DAL LAYER ?

Expecting your valuable reply - please.

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thiru on: 10/11/2011 [Member] Starter | Points: 25

Up
0
Down
I can able to check connection string in web.config file and using Enterprise Library Configuration tool.

Is there any other way to check connection string ?

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 10/11/2011 [Member] Starter | Points: 25

Up
0
Down
Who has written DAL layer,
See as you are using enterprise library it may have some base class or some class to connect to db
something similar to
DatabaseFactory.CreateDatabase("mycon ");

here mycon is the connection name
This name will take from the config file.
<configuration>

<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=XXXXX, Culture=neutral, PublicKeyToken=XXXXXXXXXX" />
</configSections>
<connectionStrings>
<add name="mycon" connectionString="Data Source=XXXXXXXXX;Initial Catalog=xXXXXX;User ID=XXXXX;PWD=XXXXXX" providerName="System.Data.SqlClient"/>
</connectionStrings>
................
..............
</configuration>


Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thiru on: 10/11/2011 [Member] Starter | Points: 25

Up
0
Down
Yes exactly.

all these code are done perfectly - but getting error.
I have already attached the required files here with.

Its getting tension :-(

If you are free - can you come on TeamViewer to get me a solution - Please.

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response