medicenpringles
Programmer
Hello again,
I need some help with a simple OLEDB query. I need to return one value from an Access database. the code below is a snapshot of what i have so far.
at the line "Price = cmdGetPrice.ExecuteNonQuery", i get an InvalidOperationException. what do i need to do to return this single value
thanks ahead of time,
stephen
-- modified at 12:47 Friday 26th August, 2005
Main Language: Visual Basic .NET
Development Environment: Visual Studio .NET 2003
I need some help with a simple OLEDB query. I need to return one value from an Access database. the code below is a snapshot of what i have so far.
Code:
Imports System.Data.OleDb
Public Class Prices
Public Shared ReadOnly Property Price(ByVal Name As String, ByVal Size As String) As Double
Get
Dim connString As String = "Data Source=""C:\Documents and Settings\user\" & _
"My Documents\Visual Studio Projects\Quiznos Register\Assoc. Files\Quiznos.mdb"";" & _<
"Jet OLEDB:Engine Type=5;" & _
"Provider=""Microsoft.Jet.OLEDB.4.0"";" & _
"persist security info=False;"
Dim conn As New OleDbConnection(connString)
Dim cmdGetPrice As New OleDbCommand("SELECT Products.Price FROM Products Products WHERE" & _
"(Products.Name='Classic Italian') AND (Products.Size='Small')", conn)
Try
If conn.State <> ConnectionState.Open Then
conn.Open()
End If
Catch ex As OleDbException
MsgBox(ex.Message)
End Try
Select Case Name
Case "Classic Italian"
Select Case Size
Case "Small"
Price = cmdGetPrice.ExecuteNonQuery '<----- This is where it gives me the error.
'other cases for other sizes
End Select
' other cases
End Select
Return Price
conn.Close()
End Get
End Property
End Class
at the line "Price = cmdGetPrice.ExecuteNonQuery", i get an InvalidOperationException. what do i need to do to return this single value
thanks ahead of time,
stephen
-- modified at 12:47 Friday 26th August, 2005
Main Language: Visual Basic .NET
Development Environment: Visual Studio .NET 2003