Solved

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

Posted on 2009-07-14
5
197 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
Comment Utility
>> 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
Comment Utility
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
Comment Utility
More points awarded to codecruiser for providing example code.
0
 
LVL 48

Expert Comment

by:jpaulino
Comment Utility
>> 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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

11 Experts available now in Live!

Get 1:1 Help Now