Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
HELP!

I am not a programmer per se, but have been using VB6 / VBA / Access for many years with plenty of success.

Trying to get to grips with VB2010 !!!

Basic gripe: I created a number of forms with datagridviews bound to a project datasource. They all work fine and update in Development mode. I have also included code to check my 2 tier access database and to re-link the tables on start-up.

However, there seems to be no way to update the project data sources to handle a deployed app running in a different directory.

I know VB.net is grown up compared to VB6, but surely this is an essential part of creating an app, and there must be a straightforward way of doing it..>>??

REALLY GRATEFUL for any suggestions, otherwise I'll ditch this product, and go back to the bad old stuff (VB6) that at least works. ;)

Ta, Steve
Posted

The ConnectionString that points to your database is in the yourprojectname.exe.config file. When you deploy, the application, you can change the ConnectionString in the yourprojectname.exe.config file to point to your "live" database.
 
Share this answer
 
v4
Might have been a duff install of VS2012 Exp, as I re-downloaded and installed on another PC, and the datasource seems to follow the EXE when you change the folder. As long as I then refresh links to any other dbs - it seems to work ok !

S
 
Share this answer
 
OK - noted, but how then do I (in either mode) set the App to point the project DataSource to the correct path ?

Where is the information held that decribes the Datasource, and what is the syntax to re-set it??

I use App_Path to handle local files, but have no idea how to change say \ProjectX\ProjectName\bin\debug to point the application datasource to where it actually is in a deployed state. I guess I could create DataSets dynamically in code (tried that a little), but various posts suggested the much quicker method I used above, so I am surprised to run into so many issues..

If I have to code it all, then so be it, and I understand that I would have more control, but in some cases - simple is good enough.

S
 
Share this answer
 
Comments
Mike Meinz 4-Feb-13 18:47pm    
I made an improvement to my Solution 1.

Put the ConnectionString that points to your data source in the CONST declarations of myConnectionString. Use the CONST declaration myConnectionString as the parameter when you create the ODBCConnection (or SQLConnection) object. If you need more than one database for debugging and more than one database for live, then add more CONST declarations.

Maybe we don't understand what you are trying to do. Perhaps if you posted some code, we might be able to offer better advice.

Also, you should not post a Solution. You should use "Have a Question or Comment?". We do not get notified when you post your own Solution.
steveRRRRRRR 5-Feb-13 2:12am    
Thanks, Because I used the project datasource, there is very little code at all, however reproduced below - most of it being added by the wizard, aside from the filter and sort I included.

The datasource point to my FRONT END Database, which has linked data from a 2nd. I do a re-link on these tables which now seems to work, but moving the project ( as in deployment) results in no rows returned (no error) as presumably the datasource cannot now find the data.

S

Public Class frmCompetitions

Private Sub frmCompetitions_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

Me.CompetitionsTableAdapter.Update(Fixtures_FEDataSet)

End Sub

Private Sub frmCompetitions_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.CompetitionsBindingSource.Filter = "CompetitionID <> 0"
Me.CompetitionsBindingSource.Sort = "CompetitionDescription" ' DESC"

'TODO: This line of code loads data into the 'Fixtures_FEDataSet.Scoring' table. You can move, or remove it, as needed.
Me.ScoringTableAdapter.Fill(Me.Fixtures_FEDataSet.Scoring)
'TODO: This line of code loads data into the 'Fixtures_FEDataSet.Competitions' table. You can move, or remove it, as needed.
Me.CompetitionsTableAdapter.Fill(Me.Fixtures_FEDataSet.Competitions)

dgCompetitions.SelectionMode = DataGridViewSelectionMode.FullRowSelect

End Sub
Mike Meinz 6-Feb-13 18:58pm    
If by "Project Datasource", you mean that you used the Dataset Designer to create a .xsd within your project, then the ConnectionString is in the yourprojectname.exe.config file. When you deploy, the application, you can change the ConnectionString in the yourprojectname.exe.config file to point to your "live" database. I updated Solution 1 with this information.

Does this help with your question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900