-1

i am working on xamarin application trying to connect this xamarin pcl(portable class lib) project with a remote database server which uses 12.2 oracle database, I found one article about connecting c# to oracle database server based on that my code something like following ...

xaml code:

 <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:datatest"
             x:Class="datatest.MainPage"
             Title="main">
    <StackLayout>
        <Button Clicked="btn_clicked" Text="click me" />
    </StackLayout>

</ContentPage>

c# code

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Oracle.DataAccess.Client;
using System.Data;

namespace datatest
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }
        string oradb = "Data Source=(DESCRIPTION =" + "(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))" + "(CONNECT_DATA =" + "(SERVER = DEDICATED)" + "(SERVICE_NAME = orcl.tdsb.on.ca)));" + "User Id= system;Password=<strong>Patel218</strong>;";


        public void btn_click(object sender,EventArgs e) {

            OracleConnection conn = new OracleConnection(oradb);
            conn.Open();
            if (conn.State == ConnectionState.Open)
            {
                DisplayAlert("connected", "wow", "ok");
            }
            else
            {
                DisplayAlert("sorry", "sorry", "ok");
            }

            // Close and Dispose OracleConnection object  
            conn.Close();
            conn.Dispose();

            if (conn.State == ConnectionState.Closed)
            {
                DisplayAlert("disconnected", "wow", "ok");
            }
            else
            {
                DisplayAlert("sorry", "sorry", "ok");
            }
        }
    }
}

And i have double checked every possible thing still its asking me for system.drawing and entity framework 6.0.0 which also i tried to enter but it is not ready to support some assemblies or some NuGet packeges now is there any other way to connect this kind of xamarin app with remote oracle database which is going to connect with the app using INTRANET connection in local area through a remote server which is on PC.

Tirth21896
  • 40
  • 10

1 Answers1

2

Create REST service, do not connect directly to external databases. Rethink you logic thinking about security (all authorization information will be available in decompiled android app), scalability and so on..