I have two TableAdapters in a project. Both are used to create a csv file that is sent to an application to create accounts. We recently moved a server so the connection string of one of the TableAdapters had to be changed. Now the fields in that one will not show up in the right order on the Dataset Designer page.
Thus it is sending the csv file to the other application with the fields in the wrong order. Is there any way to manually force those fields to show up in the correct order? The underlying SQL query does select them in the right order but they will not show up in the right order after hitting finish.
Thanks in advance for any help.
Related
I've created a DataSet related with SQL server database. This DataSet has a set of tables with TableAdapters where I've written methods to access database data. Later I've moved my database to another server, changed a connection string and tried to update the DataSet. But the Wizard just adds copies of the tables with empty TableAdapters to the DataSet.
So now I want to copy the methods of original TableAdapters to the new ones and to delete original tables after. Can I do it? Or maybe someone show me another solution.
With many tries I've got the solution! It's pretty easy:
Open your DataSet.
Right-click on first table.
Click "Configure...".
Click "Done".
Repeat steps 3-4 with all of your tables.
If you got no errors your table is updated now!
I downloaded source code of an ASP.NET MVC book and it looks this, I can see the table but I need to enter some data in it so it can show them to me
Where should I go to enter data?
While you should actually do this in SQL Server Management Studio, Visual Studio does offer you some support to deal with data. To do so, Open Server Explorer (Ctrl+Alt+S) in VS. Create a data connection, if it doesnt exist already to the DB in question by right clicking on Data Connection and click on Add Connection. Since you downloaded the source code for exercises, there is a good chance that they already created one for you. Once you have a connection to your desired database, you will be able to see database object under that including tables. To add data to a table, right click on that table and click on Show Table Data. You can then go to individual cells and enter data. Hitting enter should submit the data change to SQL Server.
Hope this helps..
So I have created a database in C#, and the mdf is in a specified location also attached to the same server (it is a backup database).
Now I want to know how to copy all the tables together with its data, definitions, and stored procedures from one table to the newly created one. Basically, they would be the same database with a different name and will be stored in a different location. I don't intend to use .bak by the way if someone suggests it.
Will I be able to do this in a query? or better yet, in C#? Or maybe I'm doing this wrong. Any suggestions will be welcome with open arms.
Summary
With Sql Server Management Studio (SSMS) you can right click on your database, select tasks, then generate scripts. This will bring up a wizard. In the Choose Objects step, you can select a radio button that will allow you to select your database tables individually. The next step Set Scripting Options will give you the ability to create a script in a single file, a file per object (table, sproc, etc). At this point you can click next through the rest of the wizard or review the steps.
If you use a script file, this can be used to recreate your database. Just modify the USE [YourDbNameHere].
Reference
https://msdn.microsoft.com/en-us/library/hh245282.aspx
I am simply writing an INSERT query to insert values into the table, when I click the submit button the code runs successfully, I don't get any error.
But when I look into the table it shows no data i.e the table is not updated. I don't know why it's happening. Can anyone suggest me.
thank you
I had the same problem if you are using c# windows application probably you have two different data base connection one updated and another still not updated so check your connections and if you are using sql express your database might be replicated in you debug directory so check your debuge folder or run your application from executable file.
What does this icon mean is Visual studio, visual Data Set designer.
I have several stored procedures.
can you help me understand,
why the one on top of the list has a
small "check mark"
why I can't delete it if I need to.
This is not the case with the rest.
Why is this "special" ?
Thanks
Because that item contains the method(s) that define the schema of the table the TableAdapter is part of.
The default names are Fill and GetData. Looks like you renamed them.
Each table has a default query (The one on top with the check on it). When you dragged your tables in to the dataset to create the query, it wrote a SQL statement which it uses to schema your table. Keep that query simple, you might not actually use it in code, and you can always edit that query to update the table schema. In the picture you provided, your default query is actually a stored procedure.
Every time you open the default query it connects to your datasource and allows you to select new columns that weren't in there before. If you want to update your existing columns, delete all the columns out of the table before you attempt to open the query. When you save the query, your updated columns get added back.
Make sure your connection string has permissions to view column information.