Solved

VB.net DataGridView run time Data Source

Posted on 2011-03-09
5
1,035 Views
Last Modified: 2012-05-11
Normally I create a DataGridView by first creating a datasource using a table or tables or a view in SQL, then I drag and drop the data source onto the dgv control.

In this case, though, I need to see if it is possible to use one dgv control, but change the data source at run time.  The purpose of the dgv will be to display the results of a select query with a WHERE clause that uses a parameter for an order number.  The VB needs to launch the query and pass in the parameter.

I can do all of that, but multiple people at different workstations will be using the dgv at the same time and passing in different parameters, so I can't just populate the datasource table with the results of the query because of the need for simultaneous access.

Is there a way that I can just run the query at the workstation and use the results of the query as the datasource for the dgv on that computer?  Or, I can send the results of the query to a unique table name for each individual user, but I still need a way to change the datasource at each computer to identify the unique table.  Can this be done?

T
0
Comment
Question by:thoecherl
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35085421
They will be using an individual installation of the application on each workstation ? yes?
The you don't need to do what you are suggesting as each application will make an individual call to the database with that users parameters.
or am I missing something here?
0
 

Author Comment

by:thoecherl
ID: 35085484
Yes, they will be using an individual installation of the app at each workstation.   But I don't know how to return the results of the query to the dgv.

My experience with using VB.net datagridviews thus far has  been to drag and drop the previously defined data source onto the dgv control and let Visual Studio create the connection. That now becomes permanent and for all of them I have done so far, the datasource is a table in SQL, not the result of an ad hoc query.

I realize this is probably pretty basic, but outside the realm of my current experience.
0
 
LVL 17

Expert Comment

by:nepaluz
ID: 35085623
you can using reflection.
there are some good tutorials on this but can not find them now. If I do, I will post, but here is one to start off

http://msdn.microsoft.com/en-us/magazine/cc163750.aspx
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
ID: 35085727
Have a look here the example is in C# but you should easily be able to convert it to vb.net with an online convertor:
http://www.codeproject.com/KB/aspnet/DataGridView__GridView.aspx
0
 

Author Closing Comment

by:thoecherl
ID: 35100517
This worked perfectly.  Thank you
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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