vb.net 获取sql server存储过程中的分类汇总结果
vb.net 调用sqlserver 存储过程
存储过程中用到了 compute 关键字
过程如下
--use k1
--GO
-- create proc fenleihuizong2
--@banji nvarchar(50)
--as
--select * from xueyuanguanli where 班级=@banji compute count(身份证号)
--go
调用代码
Dim oleDbConnection1 As OleDb.OleDbConnection
Dim strConnect As String
Dim sqlcommand As Data.OleDb.OleDbCommand
Dim sqladapter As Data.OleDb.OleDbDataAdapter
Dim sqldataset As New DataSet
Dim a As Integer
strConnect = "Provider=SQLOLEDB;Persist Security Info=False; Data Source=运营乘务王营;Initial Catalog=k1;User ID=sa;Password=123321"
oleDbConnection1 = New System.Data.OleDb.OleDbConnection(strConnect)
sqlcommand = New OleDb.OleDbCommand
sqladapter = New OleDb.OleDbDataAdapter
oleDbConnection1.Open()
sqlcommand.Connection = oleDbConnection1
sqlcommand.CommandType = CommandType.StoredProcedure
sqlcommand.CommandText = "fenleihuizong2"
sqladapter.SelectCommand = sqlcommand
sqladapter.SelectCommand.Parameters.Add("@banji", OleDb.OleDbType.Char, 50).Value = TextBox1.Text '将值传递给过程参数
sqladapter.Fill(sqldataset, "xueyuanguanli")
'之前为定义链接和打开连接()
DataGridView1.DataSource = Nothing '将记录集作为数据源赋给datafridview
DataGridView1.DataSource = sqldataset.Tables("xueyuanguanli") '将记录集作为数据源赋给
oleDbConnection1.Close()
问题
怎样获取分类汇总后的值 ?
很简单的问题见笑了!