Forum Visual Studio

sql server connection Xamarin Studio

Hi good afternoon from Mexico'm starting to program in Xamarin Studio acesoraran me and wants to make a connection with sql server Xamarin also display data in a gridview or a ListView Thanks in advance


  • ahmedaledrisiahmedaledrisi USMember

    con = new SqlConnection("data source=Ahmed-pc;initial catalog=AndroidTest;user id=sa;[email protected]");
    cmd = new SqlCommand("insert into UsersData values('" + TipPercent.Text + "')",con);
    //int time = con.ConnectionTimeout;
    //time = 30;
    int i = cmd.ExecuteNonQuery();
    if (i > 0)
    String txt = "record save!";
    Toast.MakeText(this, txt, ToastLength.Short).Show();
    Toast.MakeText(this, "record not saved!", ToastLength.Short).Show();

  • tirozhtirozh USMember

    I want to transfer my local database on the Web ,help me please.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Android.App;
    using Android.Content;
    using Android.OS;
    using Android.Runtime;
    using Android.Views;
    using Android.Widget;
    using System.IO;
    using Mono.Data.Sqlite;
    using Java.IO;

    namespace Forooshgah
    class cls_Connection
    private static string DatabaseName = "testdb.db3";
    private static string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

        private static  string DatabaseNameEndofYear;
        private static  Java.IO.File _dirBackup = new Java.IO.File(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal),  "test/backup");
        public static string getConnectionString()
            string db = Path.Combine (path, DatabaseName);
            return db;
        public static SqliteConnection setConnection()
            var databasePath = Path.Combine(path, DatabaseName);

    // return new SqliteConnection(String.Format("Data Source={0};Password={1}", databasePath, "test"));
    return new SqliteConnection(String.Format("Data Source={0};", databasePath));

        public static SqliteConnection setConnectionEndOfYear(string _fileName)
            var databasePath = Path.Combine(_dirBackup.Path, _fileName);
            return new SqliteConnection(String.Format("Data Source={0};", databasePath));
        public static string db_Name
            get{ return DatabaseName;}

    // set{ DatabaseName = value;}

        public static string db_NameEndofYear

    // get{ return DatabaseName;}
    set{ DatabaseNameEndofYear = value;}

        public static string db_Path
            get{ return path;}

    // set{ path = value;}



Sign In or Register to comment.