Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB8.0
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnview.Click
str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\db1.mdb;Persist Security Info=False"
 
conn.ConnectionString = str
conn.Open()
str = ("select Id,Name,Address,Contact_Number,Vat from table1 where Name='" & sid.Text & "','" & snm.Text & "','" & sadd.Text & "','" & Val(scno.Text) & "','" & Val(svat.Text) & "',")
 

' If rs.EOF Then
'rs.AddNew()
 
'End If
 

' If rs.EOF Then
 

sid.Text = rs.Fields(0).ToString()
 
snm.Text = rs.Fields(1).ToString()
 
sadd.Text = rs.Fields(2).ToString()
 
scno.Text = rs.Fields(3).ToString()
 
svat.Text = rs.Fields(4).ToString()
 
bu i got a same error..Item cannot be found in the collection corresponding to the requested name or ordinal. COMEXCEPTION WAS UNHANDLED
Posted 13-Jul-10 5:34am
sencsk1.2K
Edited 13-Jul-10 6:14am
v5
Comments
Dylan Morley at 13-Jul-10 10:47am
   
You've specified a field that doesn't exist - how many fields does your SQL statement return
 
What is the value of rs.Fields.Count? (check the debugger)

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This error occurs when the names of your data markers do not match the fields of the ADO recordset you are using as your data source.
 
For example, if your workbook has these data markers:
%%=categoryID
%%=description
Then the ADO recordset you assign as a data source must contain fields named "categoryID" and "description".
 
In order to be sure your ADO recordset has properly named fields, it is a good practice to use those field names explicitly in your SQL query like this:
SELECT categoryID, description FROM categories 
If you use a generic select, as in:
SELECT * FROM categories 
The query will still work if the database has the correct column names. However, it will be significantly less efficient as extra columns will be copied and subsequently ignored.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 13 Jul 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100