表A(文章表)
ID 标题表B(评论表)
tableA_ID 标题使用datagrid显示表A列表内容的时候,需要用function统计表B中的评论数量
求效率高的代码,最好不要每次都打开关闭数据库一次~我目前的代码 Public Shared Function Data_count(ByVal str As String) As String Dim Conn As SqlConnection
Conn = New SqlConnection(customSetting)
Conn.Open()
Dim Cmd As New SqlCommand("select count(id) from 表A where tablea_id=" & str, Conn)
Dim intrs As String
If Cmd.ExecuteScalar() Is DBNull.Value Then
intrs = "0"
Else
intrs = Cmd.ExecuteScalar()
End If
Conn.Close()
Return intrs
End Function
VB和C#代码均可,谢谢!!!1
ID 标题表B(评论表)
tableA_ID 标题使用datagrid显示表A列表内容的时候,需要用function统计表B中的评论数量
求效率高的代码,最好不要每次都打开关闭数据库一次~我目前的代码 Public Shared Function Data_count(ByVal str As String) As String Dim Conn As SqlConnection
Conn = New SqlConnection(customSetting)
Conn.Open()
Dim Cmd As New SqlCommand("select count(id) from 表A where tablea_id=" & str, Conn)
Dim intrs As String
If Cmd.ExecuteScalar() Is DBNull.Value Then
intrs = "0"
Else
intrs = Cmd.ExecuteScalar()
End If
Conn.Close()
Return intrs
End Function
VB和C#代码均可,谢谢!!!1
解决方案 »
- System.Data.SqlClient.SqlException: 列名 'XX ' 无效的错误
- vs2005启动问题,求帮助
- .net mvc3 不同 Action下的共用一个View
- dropdownlist设置选中的问题?
- 100 大洋求解决方案!请大鸟们帮个忙...
- 用什么方法调用web.config里已有的连接字符串?
- 再次提出紧急问题,如何将现在的时间与数据表中的时间相比较 在线急等
- 100分 !!! 分享视频资源 !!!!!!!!!
- asp.net mvc 自定义路由
- 我在Asp.net项目中用c#做了一个显示目录及图像文件的类,像Windows的资源管理器能显示缩略图及文件名,但如何能显示其它文件类型的缩略图
- 高分求教:用自己的图片,如何实现google maps的功能?
- 调用带输出参数的返回值存储过程问题
tableA_ID 标题
中有文章的ID吧?那么一个left join 连接。
把所有的数据取出来放在datatable中 然后进行分割 一部分显示上面。一部分显示下面评论信息这些
from 表A