Solved

how do I update datagrid? Please help

Posted on 2011-03-06
8
239 Views
Last Modified: 2012-05-11
Hello,

I'm extremely lost and need a little help on how to proceed.

I am making a form so when the date of birth is entered, if there's a user in the database with the same date of birth, it should update and show that user's information in the datagrid.... if it's not in the database, then it should allow the user to finish entering it in.

GOAL:
link the text box entry to check the database and update the datagrid so it displays information if available.

I think it has something to do with databinding the textbox and the datagrid together somehow, but not sure where to start...

Please help or point me in a place I can learn  

Thanks in advance for any help you can provide!
0
Comment
Question by:Obiki94
  • 3
  • 3
  • 2
8 Comments
 
LVL 17

Expert Comment

by:nepaluz
Comment Utility
OK lets start with the database, how are you calling your database?

Then, do you want an auto-complete for the textbox (I bet NOT), and if not, how does the form know that the user has completed entering the date of birth? Is there a button to press?
0
 

Author Comment

by:Obiki94
Comment Utility
I created a DataSet  (DataSet.xsd) and when I created my datagrid, I pulled from my toolbox and selected my DataSource from the list.  It's a SQL 2008 database and it's regarding only one table [users].  

Currently all the users show in the datagrid...

you are correct, no autocomplete if possible.  I've added a button on the page named (btnCheck) to be used to check the database and update the datagrid  -  if it could be done by tabbing off the field, would work too....

I'll be totally honest, I come from a long line of classic ASP and can do ADODB database connections, recordsets, etc...  but doing this in Visual Studio 2010 is a bit different.

I know I must sound like a total noob, just an old man who's went back to school to learn VB.net and it's kicking my ****.
0
 
LVL 8

Expert Comment

by:PagodNaUtak
Comment Utility
Is it windows form or a ASP.Net? The implementation of the two is different...
0
 
LVL 17

Accepted Solution

by:
nepaluz earned 400 total points
Comment Utility
So if you only require the one record to show then why do you put it in a datagridview? Anyway, that should not be my concern for now.

You will have to unbind your datagridview from the datasourse and simply make a query to the dataset / datatable and bind the result of that query to the datagridview instead. Here is some code to place in your Button_Click event

                Dim TestDS As New DataSet 'this is already defined in your case
                Dim orders = TestDS.Tables("users") 'you need this
                Dim query = From o In orders.Rows Where o("DateOFBirth") = "06/03/2011" Select o 'and this should be the result
                Me.DataGridView1.DataSource = query 'binding this to the grid should display the result. If empty, no result

Open in new window


You clould also add some code in your TextBox_Enter event to clear the datagridview datasource, thus clearing the grid.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 8

Assisted Solution

by:PagodNaUtak
PagodNaUtak earned 100 total points
Comment Utility
0
 
LVL 8

Expert Comment

by:PagodNaUtak
Comment Utility
You can also try this  one:
http://www.daniweb.com/forums/thread37972.html
0
 

Author Comment

by:Obiki94
Comment Utility
Thank you all very much!!!   I was able to make it work... now if I just don't break it.
0
 

Author Closing Comment

by:Obiki94
Comment Utility
nepaluz is awesome!!!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now