I want to be able to use the drag & drop databinding feature in Visual Studio 2012. So following this Microsoft tutorial, I added the AdventureWorks2012 mdf file to the project.
Now if I use the DataSet option in the wizard, the three database tables I want are added to the datasources window and I can do a drag & drop to create fields on my window automatically and have the binding setup.
However, that is done with SQL Adaptors. I want to use pure EntityFramework Binding instead.
Problem:
But I want to do it the EntityFramework way. If I go one step back and choose EntityData Model in the wizard, the datasource is never added. And I can't drag and drop fields from the datasource window to my MainWindow.Xaml
How can I avoid using XSD file and do it the EFway. SQL way works but it is too verbose.
Thanks
If you use a dataset, and have set up a datasource, when using EF, you must manually create a DataSource.
Here's a link to the MSDN article
Related
I am using xtrareports with my c# project and i ran into a problem. When i change the structure of one of my database table, the reports that depended on it needed to be created again because the datasource did not automatically updated itself. is there a way of doing this so that the reports are updated with the new updated datasource without having to make reports again?
Solution could be the below:
Create and configure datasets in your project
Bind a Report to a Data Source Schema
Now if you have any changes in database then update the DataSet which you added in project according the database table structure changes. It will help you easily fix the reports for the small changes e.g. column name change, column datatype
After that just open the reports in designer and again configure/modify report for the changes you made to the dataset.
Hope this way you reduce your efforts to recreate the reports from scratch..
If you mean when you add/modify a column in a procedure that feeds your report, you can:
Right click your data source in the field list menu and hit "Rebuild Result Schema"
I have created a database with several tables. Using Visual Studio 2012, I created a DataSource object that connects to those tables and created a DataGrid and some forms using the data from the SQL database.
In the process of development I then made changes to the SQL database. In one case I designated a column as a key in a table I had neglected to choose a key for. Now I want my application and the DataSource object to recognize these SQL changes.
How do I do that?
OK Bill, I believe I understand the problem now. Yes there is a way through the GUI is Visual Studio to pull the changes from your database into the Dataset you have created. Here is how you do it. Open the Data Sources Tab -> Select your DataSet You can see that mine is called People.
Now, I have updated my database by adding another column called "Phone" that I want to add to my dataset. I right click on the dataset and select Configure Data Source With Wizard.
I will expand the data objects selection and select my new column value.
Then click finish and my Dataset now has the new column in it.
I hope this helps you.
After a few failed attemps of integrating the existing Web based sql table editors to my solution, I have decided to write my own Web Based Sql Server table editor and I am thinking of using Gridview control for all the online processes on my database, here my questions:
1- Does Gridview a complete solution for SQL Server Database Table
Editor ?
2- Does Gridview the best way to do this?
P.S: What I am tring to do is creating an online admin panel of my application for an end user.
Couple of grid views and additional objects (for image viewing for example) should be enough for basic data editing.
GridView will allow you to view and edit most fields (except binary and images) from SQL table so in this respect it would work. With lookup tables you would need to use another grid view, maybe in read-only mode. It depends what you expect to have in your table editor.
You can use a sqldatasource control bound to a gridview for each table you need to manage. Sqldatasource will create CRUD operations with a wizard and Gridview will generate columns and commands automatically.
As above, you will work a bit to manage images properly, but all other fieldtype can be managed on the fly.
Datagridview is capable of operations in tables in a web interface, however auto creating a datagridview table when there is a new table added to the database is the hard part. For that reasion creating such an admin menu needs hard working, however if there won't be so much table in the application, you can create your admin panel manually with datagridviews instead of writing an own sql table editor tool.
I use Visual Studio 2010 with C# to write a database application. Until now, I used the guided dialog to add a DataSet to my current project. In the project explorer tree on the right side, a node "mydatabase.xsd" is created.
On the left side, I have the server explorer. From there, I can drag existing tables onto the DataSet-designer to create the references (to my understanding, VS auto-generates code in the background). The references (or TableAdapters etc. respectively) can be used in the source code, in the form of mydatabase.mytable
This is very convenient as I don't have to deal with the details of the connection settings, and it keeps SQL code out of my eyesight.
If, however, I want to create a new table in the existing database, VS does not seem to offer any assistance. I looked at the MSDN-specification. They tell you how to create the table object and the column definitions and how to link it to the DataSet, but not how to actually save it into the database. In all the examples I found on Google, you'd have to explicitly, manually, define a ConnectionString, SQL commands or similar. With all the VS GUI advancements, this seems rather convoluted to me. Is there an easy way to accomplish it?
Open Server Explorer, click Add Data Connection and supply connection information to your database, click OK. Right Click on Tables folder and click Add Table. Add Fields, etc to your new datatable.
I have created a dataset in a project in visual studio that points to a table in my database
and then bound a datagridview control to it.
Now I open the database and add another column to the table in the database.
Then i open the dataset and update it's configuration to include the change.
Then i want to update the datagridview, but I can't add the new column.
I can right click on the tableadapter in the form where the datagridview is and get the correct table data up.
It does not matter if I delete the tableadapter and the bindingsource and dataset instance from the form, and then try and rebind it, the datagridview still won't let me add the new column.
Does anyone have an idea what is happening?
I've tried this with several projects, both VS2008 and 2010 beta, not with other languages than C# tho.
The only solution so far seems to be to make a whole different dataset, but there has to be a better way.
Thanks in advance
Follow the following steps:
1. Go to dataset and add the new column
2. Go to the databindingsource and modify the query.
3. Go to the datagridview and add the new column
I simulated the same scenario as told by you and it worked.
If you set the GridView AutoGeneratedColumn property to tru it will auto reflect the column, but if you set it to fasle you have to add the markup in aspx page like this between <Columns> Tag
<asp:BoundField DataField="ColumnName" HeaderText="Header Text which you want to for table th " />
I hope this will work for you.
Thanks
Under the folder in
"C:\Users\YOURUSERNAME\AppData\Local\Microsoft\VisualStudio\9.0\ProjectAssemblies"
visual studio has a load of compiled things it uses for quick reference. These are named after some hashing scheme so we can't tell which one is the compiled settings for our botched table scheme.
1. We start by closing Visual Studio (I just did it to be on the safe side)
2. Delete all the folders in the ProjectAssemblies folder.
3. Open up Visual Studio again
4. Rebuild solution
5. And NOW we get the correct values when we add columns to our datagridview.
WHEW! :D