?
Solved

VB.net DataGridView run time Data Source

Posted on 2011-03-09
5
Medium Priority
?
1,050 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 2000 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

How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

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