473,788 Members | 2,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

8 New Member
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 BindingNavigato r 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 2856
dip_developer
648 Recognized Expert Contributor
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 BindingNavigato r 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
7353
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 returning database records from the bean, what common methods to people use? I've seen records returned as arraylists, but I'm not sure I like this method too well. To get the information in the next column, I can use nextElement(), but then I'm...
1
1509
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 execute it. The perfect situation for me is loop through the retrieved records then edit the values individually until EOF. Thanks, Carlo
0
1373
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 categories in that field and a total record count for the db. Now, I need to add another "total database" grouping to get another set of record counts. I DO NOT want to nest this group, It MUST consider ALL database records.
6
1393
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 Should have
9
8326
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 records in the database. Is it possible to create a SQL Server database using vb.net? I know I can use vb.net and ADOX to create a Access database. But I can't create SQL database using vb.net.
4
3954
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 SqlConnection(connectionString) Dim mySqlCommand As SqlCommand = New SqlCommand(queryString, mySqlConnection) Dim ms as MemoryStream = New MemoryStream
2
1846
by: rodchar | last post by:
hey all, what's the best way to get database records into an array? thanks, rodchar
3
1995
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 someone please help me. i have a datbase of about 90 records so far, that i would like to page thru. Thank you. James Jones
4
1435
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 need to be the ability to edit the structure of the database or tables or anything like that, simply a listing of the records and the ability to either edit/delete or create a new record in the table. I have searched google for a long time but...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10173
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.