Solved

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

Posted on 2009-07-14
5
199 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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