表中有19条记录,为何下面的SQL语句执行后,结果为0
本人估计是因为
dim total_result as integer
response.write(total_result)
————————————————————
dim 语句定义了一个新的变量,变量未赋值,所以得出初始值为0,那么SQL中的total_result如何获取?
_____________________________________________________________
<%@ import namespace="system.data" %>
<%@ import namespace="system.data.oledb" %>
<%@ Page Language="VB" %>
<script runat="server">
sub button_click(sender as object,e as eventargs)
dim dsn as string
dsn="provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("../db.mdb"

& ";"
dim conn as oledbconnection=new oledbconnection(dsn)
conn.open
dim strsql as string
strsql="select count(*) as total_result from product"
dim cmd as oledbcommand=new oledbcommand(strsql,conn)
dim reader as oledbdatareader=cmd.executereader()
dim total_result as integer
response.write(total_result)
end sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:button id="button" runat="server" text="Result" onclick="button_click" />
</form>
</body>
</html>