Ok, so I've got this Visual Studio 2008 Project I was working with about a year ago perhaps. And this project had a datagrid that was linked to an external database running on a server off the internet. Now, this databinding was all done using Visual Studio 2008's built in features. But how can I now change the binding to a different server, without destroying the project? I've noticed that a lot of the code that Visual Studio creates makes a mess. So manually trying to change the datasource has allways f*cked up the whole project for me.
I'm not all that good with this stuff, that's why I used the built in features of Visual Studio. But I noticed that several things appear, like a binding source, and a dataset. Is it possible to do this? Perhaps even better, making these settings be controlled after the program has been compiled. The way it is开发者_高级运维 now, it's all hard coded after compiling, and that kinda sucks. I remember trying to do this about a year ago, trying to bind these settings to variables stored in settings. But I never got that to work. Just throwing around ideas here :)
Any help, pointers or whatever is highly appreciated! :)
In the Solution Explorer window, "show all files". If you expand out the files under your form, you can find the Form1.Designer.vb file. This is the code that VS generated to support those "built in" features you used.
Look at the code in this file and search for the name of your old server. Hack away.
Today in 2021 using Visual Studio 2019, the best way to do this is to edit the App.config file.
Open this file and you'll see the connection string that the rest of the application uses to connect to the Database. Change this here and everything else should fall into place.
The easiest thing to do is:
- In a new project, create a new data source that points to the new database
- Copy the contents of the App.config file from this new project into the App.config file of your old project (taking a backup of course)
This is what I just did to transfer from using an MDF file as a data source to an actual instance of SQL Server.
精彩评论