using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace Database
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        int baseExp = 200,currentExp,lvl=1,str,intel,dex,armr,min=10,max=25,minimum=2,maximum=3;
        public void levelUp()
        {
            min += minimum;
            max += maximum;
            str = int.Parse(strength.Text);
            intel = int.Parse(intelligence.Text);
            dex = int.Parse(dexterity.Text);
            armr = int.Parse(armor.Text);
            if (currentExp > baseExp)
            {
                currentExp -= baseExp;
                lvl+=1;
                baseExp += 250;
                str += 1;
                intel += 1;
                dex += 1;
                armr += 1;
                strength.Text = str.ToString();
                intelligence.Text = intel.ToString();
                dexterity.Text = dex.ToString();
                armor.Text = armr.ToString();
            }
        }
        private void addExpBtn_Click(object sender, EventArgs e)
        {
            Random rand = new Random();
            int num = rand.Next(min, max);
            currentExp += num;
            levelUp();
            levelLbl.Text = lvl.ToString();
            currentExpLbl.Text = currentExp + "/" + baseExp;
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            currentExpLbl.Text +="/" + baseExp.ToString();
        }

        private void saveBtn_Click(object sender, EventArgs e)
        {
            OleDbConnection myconn = new OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source = CharacterDatabase.mdb");
            myconn.Open();
            string upDateSql = "UPDATE [JumpChars] set Lvl='" + levelLbl.Text + "', strength ='" + strength.Text + "', dexterity ='" + dexterity.Text + "', intelligence='" + intelligence.Text + "', armor ='" + armor.Text + "', health ='" + hp.Text + "', mana ='" + mp.Text + "', exp ='" + currentExp.ToString() + "' " + "WHERE CharName ='" + name.Text + "'";
            OleDbCommand update = new OleDbCommand();
            update.CommandText = upDateSql;
            update.Connection = myconn;
            update.ExecuteNonQuery();
            myconn.Close();

        }
    }
}

Recommended Answers

All 4 Replies

Are you getting any errors? If so:

  • what is the error?
  • what line does it occur?

It is quite hard to run code in your head and generate errors that you have no clue about.

it doesnt have any errors,when i run it,then when i click update button,it doesn't update in my access database

I solved it already. :D Sorry guys for wasting your time. :|

No worries, what was the issue in the end :)?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.