ADOQuery1->SQL->Add,这里面的内容是什么类型,字符串吗?
ADOQuery1->SQL->Add("delete from terminal where id = btn_delete->Tag ");
比如我要实现这样的功能该怎么写,在前面先加个变量把这个值先转成字符串 String s = IntToStr(btn_delete->Tag);
ADOQuery1->SQL->Add("delete from terminal where id = s ");
但是这样感觉也不对啊,这里面的"s"是我的变量s 还是字符串"s"呢?
这里面的内容到底要是什么类型的,怎么写进去?
[解决办法]
ADOQuery的SQL属性是TStrings类型,SQL->Add函数能接受的参数是String类型。你构造一个String对象代入即可:
String strSQL;
strSQL = String("delete from terminal where id = ") + btn_delete->Tag;
或
strSQL = "delete from terminal where id = " + String(btn_delete->Tag);
或
strSQL = "delete from terminal where id = " + IntToStr(btn_delete->Tag);
或
strSQL = String("delete from terminal where id = ") + IntToStr(btn_delete->Tag);
或
strSQL = String().sprintf(TEXT("delete from terminal where id = %d"), btn_delete->Tag);
都可以实现赋值,然后:
ADOQuery1->SQL->Add(strSQL);
[解决办法]