Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
ASP.NET/Access Query not returning data
Old 03-18-2005, 07:28 AM ASP.NET/Access Query not returning data
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
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
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
 
Register now for full access!
Old 03-18-2005, 10:57 AM
vivekar's Avatar
Webmaster Talker

Posts: 612
Trades: 0
Did you use Reader.Read()?
__________________

Please login or register to view this content. Registration is FREE
(Active since 2003) |
Please login or register to view this content. Registration is FREE
vivekar is offline
Reply With Quote
View Public Profile Visit vivekar's homepage!
 
Old 03-18-2005, 11:01 AM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
I knew I'd forgotton something
Not used to working with Access...
__________________
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
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Reply     « Reply to ASP.NET/Access Query not returning data
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13450 seconds with 12 queries