hey all again
i have a little issue it may be a little stupid but i'm not able to figure it out
what i'm trying to do is to make a counter ,, i'm trying to get a number from database and increment 1 to it and adding it one more time to the table but it seem that i'm not able to do it and here what i came to right now

string CounterSql = "SELECT counter from counters where ctrtype = 'station'";
            OleDbCommand CBCmd = new OleDbCommand(CounterSql, AMSCONN);
            AMSCONN.Open();
            OleDbDataReader CBReader = CBCmd.ExecuteReader();
            DataTable CounterDT = new DataTable();
            CounterDT.Load(CBReader);
            Code_txt.Text = CounterDT.Rows.ToString();
            AMSCONN.Close();

but it dosen't seem to worek so..... is there is any way to fix this or even improve it ??

    string CounterSql = "SELECT counter from counters where ctrtype = 'station'";
    OleDbCommand CBCmd = new OleDbCommand(CounterSql, AMSCONN);
    AMSCONN.Open();
    OleDbDataReader CBReader = CBCmd.ExecuteReader();
    if(CBReader.read())
    Code_txt.Text=(int.parse(CBReader[0].toString())+1).toString();
    else
    Code_txt.Text="1"
    AMSCONN.Close();
commented: Line 6 makes my brain explode. -2
commented: i don't know exactly what's wrong with line 6 but it seemed to worked fine , thanks !! +0
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.