VB程序员博客

VB程序开发

如何提取数据库表1的序号列的最大值并在TEXTBOX中显示?
有高人能写个代码吗
我是用的VB6.0编程软件 用ADODC连接数据库的
写Text1.Text="select max(序号) from 表1"为什么不行报错吗,这里是一个赋值的部分代码
——————————–
set rs=server.createobject("adodb.recordset")
sql="SELECT * FROM table"
rs.open sql,conn,1,1
'显示数据
text1.text=rs("filed1")也不是报错  把Text1.Text="select max(序号) from 表1"写在一个按扭控件下 按这个控件是没反映有人知道么试试这样行不行:
sqltxt="select 序号 from 表1 order by 序号 DESC"        '降序排列
adodc1.recordset movefirst
text1.text=adodc1.recordset.fields("序号")

或者:
sqltxt="select max(序号) as xh from 表1 group by 序号"
text1.text=adodc1.recordset.fields("xh")谢谢楼上的 我去试下可以先参考一下ADO手册中的例子是如何访问数据库的。

楼主太牛 sql 语句这样直接用

标签: , , ,