Hi All,
I have the following function:
Code:
Private Function GetContactEmail(ID As Integer) As String
Dim Connection As OleDbConnection = New OleDbConnection(ConfigurationSettings.AppSettings("DBString"))
Dim Command As OleDbCommand = New OleDbCommand("GetContactEMail", Connection)
Command.CommandType = CommandType.StoredProcedure
Dim pID As OleDbParameter = New OleDbParameter("@ID", OleDbType.SmallInt, 4)
pID.Value = ID
Command.Parameters.Add(pID)
Connection.Open()
Dim Reader As OleDbDataReader = Command.ExecuteReader()
Dim Result As String
Result = Reader.GetString(0)
Return Result
Connection.Close()
End Function
As you can see it calls a query in Access and passes an ID, this should return 1 string field:
Code:
SELECT EMail
FROM Queries
WHERE ID=[@ID];
I have run the query in Access and it works fine. I have tested that pID.Value contains the right data, but when I try and run the function, I get:
Exception Details: System.InvalidOperationException: No data exists for the row/column.
Any ideas?
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"
Please login or register to view this content. Registration is FREE | Please login or register to view this content. Registration is FREE
|