【发布时间】:2013-02-27 15:40:20
【问题描述】:
我在 SQL Server 中有一个存储过程,我创建了一些内部连接,现在我将如何使用该存储过程填充我的数据网格。
这是我的代码不起作用
Dim cmd As New SqlCommand
Dim reader As SqlDataReader
cmd.CommandText = "OfficeEquipmentProfile"
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = sqlconn
sqlconn.Open()
sAdapter = New SqlDataAdapter(cmd)
sBuilder = New SqlCommandBuilder(sAdapter)
sDs = New DataSet
sAdapter.Fill(sDs, "tblOfficeEquipmentProfile")
sAdapter.Fill(sDs, "tblDepartment")
sAdapter.Fill(sDs, "tblLocation")
sAdapter.Fill(sDs, "tblOfficeEquipmentCategory")
sAdapter.Fill(sDs, "tblApplication")
sAdapter.Fill(sDs, "tblApplicationLicense")
sAdapter.Fill(sDs, "tblEquipmentApplication")
sAdapter.Fill(sDs, "tblOfficeEquipmentBrand")
sAdapter.Fill(sDs, "tblOfficeEquipmentModel")
sAdapter.Fill(sDs, "tblOfficeEquipmentServiceOrder")
sAdapter.Fill(sDs, "tblOfficeEquipmentPMplan")
sTable = sDs.Tables("tblOfficeEquipmentProfile")
sTable = sDs.Tables("tblDepartment")
sTable = sDs.Tables("tblLocation")
sTable = sDs.Tables("tblOfficeEquipmentCategory")
sTable = sDs.Tables("tblApplication")
sTable = sDs.Tables("tblApplicationLicense")
sTable = sDs.Tables("tblEquipmentApplication")
sTable = sDs.Tables("tblOfficeEquipmentBrand")
sTable = sDs.Tables("tblOfficeEquipmentServiceOrder")
sTable = sDs.Tables("tblOfficeEquipmentPMplan")
DataGrid1.DataSource = sDs.Tables("tblOfficeEquipmentProfile, tblDepartment, tblLocation, tblOfficeEquipmentCategory, tblApplication,tblApplicationLicense, tblEquipmentApplication, tblOfficeEquipmentBrand, tblOfficeEquipmentServiceOrder,tblEquipmentPMplan")
DataGrid1.ReadOnly = True
'Button1.Enabled = False
'DataGrid1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
reader = cmd.ExecuteReader()
sqlconn.Close()
我只想显示数据库中的记录
【问题讨论】:
-
没有返回错误,同时没有显示数据库中的任何记录
-
请显示您的存储过程。我看不到你在 cmd.parameter 中调用的参数
-
我的存储过程太长了如何显示?
-
您的存储过程需要什么参数?当您在 .net 代码中调用此存储过程时,我看不到任何参数
-
请将您的电子邮件发送给我,我的电子邮件是 ivan.jerome003@gmail.com
标签: sql vb.net datagrid visual-studio-2003