Solved

VB.net DataGridView run time Data Source

Posted on 2011-03-09
5
1,029 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

708 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

12 Experts available now in Live!

Get 1:1 Help Now