Results 1 to 2 of 2

Thread: save data

  1. #1
    Join Date
    Jul 2010
    Posts
    1

    Unanswered: save data

    Code:
    public partial class Databasen : Form
        {
            public static String[,] StringSlag = new String[22, 4];
            DataSet DataS = new DataSet();
            SqlDataAdapter DataA;
            SqlConnection databasen = new SqlConnection();
            public static int Spelare;
    
             private void btnSpara_Click(object sender, EventArgs e)
            {
                System.Data.SqlClient.SqlCommandBuilder command;
                command = new System.Data.SqlClient.SqlCommandBuilder(DataA);
                databasen.ConnectionString = 
                "Data Source=.\\SQLEXPRESS;AttachDbFilename=" + Application.StartupPath + "\\resultat.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
                databasen.Open();
                DataRow Spara = DataS.Tables["Sparningar"].NewRow();
                Spara[0] = cbbSparadeSpel.Text;
                Spara[1] = Spelare;
                DataS.Tables["Sparningar"].Rows.Add(Spara);
                DataA.Update(DataS, "Sparningar");
                DataRow Spara2 = null;
                for (int j = 0; j == Spelare - 1; j += 1) {
                    Spara2 = DataS.Tables["SlagResultat"].NewRow();
                    for (int i = 3; i >= 26; i += 1) {
                        Spara[i] = StringSlag[i - 3, j];
                    }
                    DataS.Tables["Sparningar"].Rows.Add(Spara2);
                }
                DataA.Update(DataS, "Sparningar");
                databasen.Close();
                databasen.Dispose();
            }
          }
    Well the this code is work when the application is on but if i close my program the data is not in my database. So if i could get some help then i would be great.
    Last edited by frozendragon498; 07-06-10 at 14:47.

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Somehow your connection object acquires SET IMPLICIT TRANSACTIONS ON setting. So once you close the app, all transactions are rolled back.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •