开发者

SharePoint Visual web part and Oracle connection problem

I'm trying to build a "visual web part" for SharePoint开发者_如何学JAVA 2010 which should connect to Oracle table and display records on SharePoint page.For development, Oracle 11g client (with ODP.net) ,SharePoint server 2010, Visual Studio 2010 and Oracle 10g express all running on my machine.

First,I've written sample code in ASP.NET web app to connect my local Oracle table and display data in grid view and it works fine. My code is ,

OracleConnection con;
            try
            {
                // Connect
                string constr = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XE)));User Id=SYSTEM; Password=password";

                con = new OracleConnection(constr);

                //Open database connection
                con.Open();

                // Execute a SQL SELECT
                OracleCommand cmd = new OracleCommand("select * from T_ACTIONPOINTS WHERE AP_STATUS='Active' ", con);
                OracleDataReader dr = cmd.ExecuteReader();

                GridView.DataSource = dr;

                GridView.DataBind();
                GridView.AllowPaging = true;

            }
            catch (Exception e)
            {
                lblError.Text = e.Message;
            }

Now, I'm trying to create new "SharePoint" visual web part project and using same code and deploying it on my local SP server. But when it runs , I get following error

SharePoint Visual web part and Oracle connection problem

here is my solution explorer,

SharePoint Visual web part and Oracle connection problem

It looks something wrong in compatibility.Can someone point me in right direction ?


In Visual Studio 2010, references are not always included in the solution package by default. So just because it is in the project references, does not necessarily mean it will make the trip to the server. To check if your DLL is in the solution package:

  • open Package from the Solution Explorer
  • click the Manifest tab

Do the following steps, if your DLL is not listed in the Assemblies section:

  • click the Advanced tab
  • under Additional Assemblies, click Add > Add Existing Assembly...
  • locate your DLL and click OK


Do you have Oracle.DataAccess.dll . You need to put it in bin directory of sharepoint web application.

Alternatively, you must be referring it in your web part as a reference. Make sure that this DLL is included in your solution package.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜