Solved

VB.net DataGridView run time Data Source

Posted on 2011-03-09
5
1,047 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

707 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