我在MySQL数据库上有这样的代码:
MD-54564
MD-54565
MD-54566
所以我需要获取下一个代码并尝试这样的事情:
string code_select = "SELECT MAX(CAST((SUBSTRING(code,4)) as UNSIGNED)) FROM table WHERE code like 'MD-%'";
DataTable code = new DataTable();
code = conexion.mySelect(code_select);
num_code = Int32.Parse(code);
num_code = num_code + 1;
code= "MD-" + num_code.ToString();
这是在第4行给我CS1502 error
。
答案 0 :(得分:1)
你可以在@Bean
ObjectMapper dateObjectMapper() {
// ...
}
@Bean
@Primary
ObjectMapper defaultObjectMapper() {
// ...
}
附近添加`来逃避这个词,因为它在MySQL中是keyword
。
以下代码正在运行:
code
答案 1 :(得分:0)
string code_select = "SELECT MAX(CAST((SUBSTRING(code,4)) as UNSIGNED)) + 1 AS NextNumber FROM table WHERE code like 'MD-%'";
DataTable code = new DataTable();
code = conexion.mySelect(code_select);
DataRow row = code.Rows[0];
reg_num = row["NextNumber"].ToString();
cod_ev = "MD-" + reg_num;