How to get last code from column in table

To get the last code from table in mysql , example we want to show last id from idcustomer to textbox , the code is below

Private void Form1_load(Object sender, EventArgs e){

string connection = “Server=servername;user=username;database=dbsales”;
string kode;
int iNumber,iHasil;
MysqlConnection conn = New MysqlConnection();
MysqlReader reader ;
MysqlCommand comm = New MysqlCommand();
conn = New MysqlConnection(connection);
comm = con.CreateCommand();
comm.CommandText = “Select id from idcustomer;”;
while ({
kode = Reader.GetString(“idcustomer”);
iNumber = Convert.ToInt32(kode);
iHasil = iNumber + 1;
Textbox1.Text = iHasil.ToString;

Leave a Reply