Solved

Representing columns data in Visual Basic .Net from a SQL database

Posted on 2009-07-14
5
198 Views
Last Modified: 2013-11-26
Hello,

I am writing a simple app in Visual Basic 2008 that will pull some data from a SQL database using a rather complex query and represent it in a form. Once this data is retrieved, a complex set of operations are carried out and displayed on another form in a similar tabular format

What is the best element to use to display this data (table, grid, etc). I know I can use datagridview, but i dont need the connection to be "live" - just extraction. Nothing needs to be written back to the database either. I imagine a listbox would work, but I would prefer that the end user have a simplistic excel-like interface.

Any example declarations would be greatly appreciated.

Thanks in advance.
0
Comment
Question by:ashbrookcorp
  • 2
  • 2
5 Comments
 
LVL 48

Assisted Solution

by:jpaulino
jpaulino earned 100 total points
ID: 24854702
>> but I would prefer that the end user have a simplistic excel-like interface.

But the DataGridView don't need to save the change back to the database. In fact you have to write some code in order to do that.
 
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 400 total points
ID: 24857856
As said by JPaulino, datagridview does not write back to the database automatically if you do not configure it to do so. So you can retrieve the data from the db into a datatable. Use that datatable as the datasource of the grid and any changes made would remain in the datatable.

Here is an example of how to load and display using datatable


dim dTable as new datatable

dim dbadp as new sqldataadapter("select * from tablename", connectionstring)

dbadp.fill(dTable)

dbadp.dispose

datagridview1.DataSource = dTable

Open in new window

0
 

Author Closing Comment

by:ashbrookcorp
ID: 31603491
More points awarded to codecruiser for providing example code.
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24872828
>> More points awarded to codecruiser for providing example code.
You didn't asked that :)
No problem ... glad I could help.
0
 

Author Comment

by:ashbrookcorp
ID: 24878050
yeah i did!

>> Any example declarations would be greatly appreciated.

No matter. You contribute some great stuff to this forum - plus you are in the hall of fame here man!! :) (congrats on #1, BTW)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

26 Experts available now in Live!

Get 1:1 Help Now