【发布时间】:2016-06-08 23:04:53
【问题描述】:
我只是在使用 Asp.Net/VB/SQL 的网站上学习和工作。我正在尝试从 SQL 中读取一整行数据以在我的 VB 代码中进行操作。到目前为止我有这个..
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT shopName
,shopLogo
,addressLine1
,city
,postcode
,phoneNumber
,pointsPerPound
,maxPoints
,info
FROM tblShopKeeper
WHERE orderID = @shopID
END
选择数据但如何将其传递回 VB ? 我有这个作为代码..
Public Function SelectShop(ByVal orderString As Guid) As String
Dim DBConnect As New DBConn
Using db As DbConnection = DBConnect.Conn("DBConnectionString")
Dim cmd As SqlCommand = DBConnect.Command(db, "SelectShop")
cmd.Parameters.Add(New SqlParameter("shopID", SqlDbType.uniqueIdentifier, ParameterDirection.Input)).Value = orderString
db.Open()
Dim shopName As String
Dim shopLogo As String
Dim addressLine1 As String
Dim city As String
Dim postcode As String
Dim phoneNumber As String
Dim pointsPerPound As Integer
Dim maxPoints As Integer
Dim info As String
Dim DR As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
While DR.Read
shopName = DR("shopName")
shopLogo = DR("shopLogo")
addressLine1 = DR("addressLine1")
city = DR("city")
postcode = DR("postcode")
phoneNumber = DR("phoneNumber")
pointsPerPound = DR("pointsPerPound")
maxPoints = DR("maxPoints")
info = DR("info")
End While
DR.Close()
DR = Nothing
cmd.Dispose()
cmd = Nothing
db.Dispose()
db.Close()
Return shopName
End Using
End Function
我只是简单地用.. 选择商店(shopID)
“返回”语句只允许我传回一个字段。请问如何将所有字段传回以在代码中使用?
温柔点.. 我只是个新手 :-) 非常感谢。
【问题讨论】: