Update Database

Govind Sankar

Active member
Joined
May 15, 2020
Messages
42
Programming Experience
Beginner
I have a database with 2 tables in SQL Server and I have a C# program that connects to the database in Visual Studio and also a dataset is created from the database. I need to add a column to the table. So what I did is added the two columns using microsoft sql server management studio and then tried updating it in Visual Studio. The database in visual studio gets updated with the new table but the dataset doesnt change even after refreshing. So is this the right way. Or should I do it in the reverse order that is update the dataset in Visual Studio and using that try to update the Database. Kindly do help me.
 

Attachments

  • LearnByDoing2.zip
    249.4 KB · Views: 21
There are two ways to create a SQL Server database for your application. You can create it in SSMS and it will then be permanently attached to your local SQL Server instance. If that's how you created the database then that's how you modify the database, i.e. in SSMS. You can also create the database in VS. In that case, the MDF data file is added to your project and is attached to the instance when you run the app. If that's how you created the database then that's how you modify the database, i.e. in VS. Either way, when you create a Data Source, it retains the connection string for the database. After you make a schema change, open the Data Sources window and click the button on the tool bar that says something like Refresh from Database. That will push any new schema from the database to the Data ourcet. Any schema you have removed will have to be removed from the DataSet manually.
 
There are two ways to create a SQL Server database for your application. You can create it in SSMS and it will then be permanently attached to your local SQL Server instance. If that's how you created the database then that's how you modify the database, i.e. in SSMS. You can also create the database in VS. In that case, the MDF data file is added to your project and is attached to the instance when you run the app. If that's how you created the database then that's how you modify the database, i.e. in VS. Either way, when you create a Data Source, it retains the connection string for the database. After you make a schema change, open the Data Sources window and click the button on the tool bar that says something like Refresh from Database. That will push any new schema from the database to the Data ourcet. Any schema you have removed will have to be removed from the DataSet manually.
Yes it was case number 1, that is it was created in SSMS. I created in SSMS and then connected to it in Visual Studio but then the actual database is in SSMS. I did update it in the SSMS but I couldnt update the dataset in Visual Studio. After updating the Database in SSMS and then I tried to update the dataset in Visual Studio by pressing refresh button. But it didnt work. That is my doubt.
 
Back
Top Bottom