473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Displaying Specific Database Records in a Form (VB .NET)

Hi there,

I'm fairly new to using databases with VB .NET. I'm currently working on an application using a Microsoft Access database as a data source. I have created a form to display the fields for each record in a particular table (using the feature that allows you to drag and drop a field from a table in the database onto the form, automatically attaching a BindingNavigator and TableAdapter and all that jazz to it). As you probably know, when the application is run the form will display all records in the table.

What I want to be able to do is find particular records in the table and display only these records on the previously mentioned form (there will be at least one record, but occasionally more).

I can successfully find the records I need from the database, but I can't seem to get the form to display only those records. Instead, it still displays ALL of the records in the table.

Currently, I am retrieving the relevant records from the database then storing them in an array of objects (and this works fine). I retrieve the row number of the first object in the array (I was just trying to get one working first) and then set the myBindingSource.Position property to that row number. However, this does nothing, and as I said the form still shows all of the records in the table (starting at the first record) rather than the required record. I'm also not sure how to go about limiting the number of records displayed.

I don't really know what options are available for me to get this working. I would appreciate any help at all at this stage.

Cheers,

dheroan
Oct 24 '07 #1
1 2746
dip_developer
648 Expert 512MB
Hi there,

I'm fairly new to using databases with VB .NET. I'm currently working on an application using a Microsoft Access database as a data source. I have created a form to display the fields for each record in a particular table (using the feature that allows you to drag and drop a field from a table in the database onto the form, automatically attaching a BindingNavigator and TableAdapter and all that jazz to it). As you probably know, when the application is run the form will display all records in the table.

What I want to be able to do is find particular records in the table and display only these records on the previously mentioned form (there will be at least one record, but occasionally more).

I can successfully find the records I need from the database, but I can't seem to get the form to display only those records. Instead, it still displays ALL of the records in the table.

Currently, I am retrieving the relevant records from the database then storing them in an array of objects (and this works fine). I retrieve the row number of the first object in the array (I was just trying to get one working first) and then set the myBindingSource.Position property to that row number. However, this does nothing, and as I said the form still shows all of the records in the table (starting at the first record) rather than the required record. I'm also not sure how to go about limiting the number of records displayed.

I don't really know what options are available for me to get this working. I would appreciate any help at all at this stage.

Cheers,

dheroan

why are you not using sql???
a simple select query with your condition will do everything.......

take a DataSet(say ds)...fill dataset with a DataAdapter(say da).......Populate a Datagrid or Gridview or Table with your DataSet

i am giving you a code snippet in VB.NET..................

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim sqlString As String="Select myrecord FROM myTable WHERE myColumn=myCondition"
  3. da = New OleDbDataAdapter(sqlString , myConnection) 
  4. ds = New DataSet
  5. da.Fill(ds)
  6. dg.DataSource=ds
  7. dg.DataBind()
  8.  
Oct 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dan | last post by:
Hello, I'm getting started on my first java project. I'm likely going to use jsp/servlets connected to javabeans. The beans will connect to my backend and get/set information for me. When...
1
by: Carlo Chung | last post by:
How to use db-lib to update/insert database records without using SQL language. I want to change the value of the data individually without plugging in the new values in the SQL language then...
0
by: Richard Holliingsworth | last post by:
Hello: I'm building a report to display statistics on the entire database. I have successfully built a report that groups the entire db on one field and gives me a count of db records for the...
6
by: alsemgeest | last post by:
Hi, I'd like to make a valuation of database records. Suppose you have a table: Name Must have Address Should have Zip Should have SocialSecNr Must have City ...
9
by: Peter | last post by:
Hello£¬everyone, My program will collect a testing machine's data ,save the data and deal with the data everyday. I want to use vb.net to create database, add and delete tables or modify the...
4
by: Lindsey Howell | last post by:
Hello, I've encountered a problem when trying to display BLOB images from a SQL database using VB.NET. This is the code which generates the error: Dim mySqlConnection As SqlConnection = New...
2
by: rodchar | last post by:
hey all, what's the best way to get database records into an array? thanks, rodchar
3
by: Jay | last post by:
i post a while back on how to page thru database records. i dont really understand the ASPFAQ one. Its not well commented. This is how i learn anything, is if its commented on what does what. Can...
4
by: Ronald Raygun | last post by:
I need to dynamically create a page that allows me to edit records in a a database table. Basically, something very similar to how PHP MyAdmin works only slighly less complicated. There does not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.