Jump to content
Minmoas

Ligar a base de dados a aplicação

Recommended Posts

Minmoas

boas.

eu to a tentar ligar a minha base de dados a minha aplicaçao:

e uma coisa bem simples o que eu quero fazer, eu no meu layout, tenho 1 botao e uma edite box , eu quero que tudo o que eu escreva nessa edite box va para a base de dadados assim que carregar no botao, layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <EditText
        android:inputType="textPersonName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txtName"
        android:text="Name" />
    <Button
        android:text="Inserir"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/btnInserir" />
</LinearLayout>

o codigo do botao que estou a fazer esta aqui:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using System.Net;

namespace APP_Sport_Life_2
{
    [Activity(Label = "Teste", MainLauncher = false, Icon = "@drawable/Logo")]
    public class layout1 : Activity
    {
        string usr;

        public MySqlConnection
        protected override void OnCreate(Bundle bundle)
        {
            SetContentView(Resource.Layout.layout1);
            base.OnCreate(bundle);
            //fazer o programa saber onde estao os botoes e em que layouts
            var btnInserir = FindViewById<Button>(Resource.Id.btnInserir);
            //Faz o programa saber que cada botao recebe uma ordem quando e clicado
            btnInserir.Click += btnInserir_Click;
        }

        private void btnInserir_Click(object sender, EventArgs e)
        {
            
        }
    }

}
    /*public class CreateContactEventArgs: EventArgs
    {
        public string Name { get; set; }
        public string Number { get; set;}

        public CreateContactEventArgs(string name, string number)
        {
            Name = name;
            Number = number;
        }
    }


   public class layout1 : DialogFragment
    {
        public event EventHandler<CreateContactEventArgs> OnCreateContact;
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.layout1);

            // Set our view from the "main" layout resource

            var btnTeste = FindViewById<Button>(Resource.Id.btnTeste);
            btnTeste.Click += btnTeste_Click;
        }

        void btnTeste_Click(object sender, EventArgs e)
        {
            WebClient client = new WebClient();
            Uri uri = new Uri("teste2.mdf");
                if()
        }
    }*/

nao sei realmete como fazer entao se me podessem ajudar agradecia :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.