I have created views in sql how can I use in Linq query
I have get data from many tables and calculate stockIn,stockOut,StockClearence and StockRejection how can i do this by using Views.
Please any one give me the reference website for views using Linq
I developed application in c#.net. desktop application
Thanks in advance
The same as tables. Except that you can't update, insert, delete and have entity relations.
Everything else is the same. Just drop the view on the DBML designer surface.
If you have defined the views in you SQL Server Database, they'll appear in the Server Explorer and can be dragged and dropped onto the DBML diagram. The view(s) will not have any relation to other tables. You are suppose to create a related view for your screen requirements and the exact view will be translated by SQL Metal for the DBML file. You can bind the view and/or read it. Views only allow SELECT.
Related
I am looking for a tool like mssql workbench where I can draw my database diagram, but for mssql instead. I am programming in asp.net core and would like to have the tool auto generate a diagram based on my existing models, but also let me modify (but not necessarily generate the classes) the diagram after.
You can use "Database Diagrams" feature from MSSQL Management Studio.
Open MSSQL Management Studio, Connect to the SQL Server and select the database.
Under selected database you should be able to find node "Database Diagram". Right click on it and select "Add new diagram".
You can create diagram from the existing tables in the database and also create new tables as well as modify existing table.
You also can save the diagram as JPEG format.
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.
Basically all I want is to be able to create like a self contained database in my Windows Forms application, I do not want to connect to a server or anything like that with SQL Server, I just want like a small database in the application that can handle a few transactions.
Like for instance if I create a Windows Forms application then it would have its own small database in it and when deploying it.. it will save rows there and stuff. I remember hearing about a plug in, it started with a CT or something don't recall, but it would be a plugin for Visual Studio.
Any help would be much appreciated.
Regards
You can use SQL Server Compact or SQLite (ADO.NET provider is available here). Both are embedded database engines that run in-process. You don't need to install anything, just include the appropriate DLLs with your application.
Visual Studio has no problem providing you with just such a database. Just right click your project, add new item, and select SQL Server Database. The database created will be part of your project and can be deployed as needed.
If you have a limited amount of data you can just right-click the project and Add a DataSet. Then you can define multiple tables in the .xsd and store multiple rows. in the .xml. Then you can write some simple code in the .xsd code-behind to auto load and save defaults and even pull back rows of data. I typically use this approach for storing a single record in each table. It will also work with multiple records in each table. There's a point where if you start to get a lot of data you'll probably wish you had used something like SQL Compact Edition or something similar that you bundle with your app.
you can use sqlLite,this is the website
http://www.sqlite.org/
or you can use access too
Im using c# .net windows form application.
I have many databases created using sql server Management studio 2005. Each database has several tables. i have a button, when clicked should allow me to select a database among several databases and in that database i want to select a single table. Later i need to display the contents of the selected table into a datagrid view.I came to know that it can be done using Webconfig. How can i acheive this?
It goes like this
a) select a database
b) In that database select a table
c) display the contents into a datagridview.
You got some things mixed up a bit. A web.config file is only used for web applications created with ASP.Net.
For windows application you can use the App.config file, which is like the web.config for web applications. As part of the app.config is the "connectionStrings" section which contains one or multiple connection string for database connections. Take a look at this page:
http://msdn.microsoft.com/en-us/library/ms254494%28VS.80%29.aspx
In code you then can retrieve the connections string via the ConfigurationManager.ConnectionStrings properties.
It is called "programming". Good enough an answer? I mean, you basically ask a LOT ;)
Ok, here some details:
You need to log into the server, obviously.
Then find out what databases exist. MASTER database is your friend - look at the sys schema there, you will find out the tables there contain all information.
Then you need to find out what tales exist. The INFORMATION_SCHEMA is your friend. It exists in every database. It has nice views that allow you to ask for tables, columns etc.
From there on it is some low level beginner training - given a database and table name, how do you get the data? ;)
I am currently learning C# and LINQ. I have lots of questions about them. Basically, I need a step by step tutorial.
I suppose the dbml file is the configuration file of the database. If I double click the dbml file VS will open it in a design diagram. Can I create/delete/modify tables here? I can use add new item to add the LINQ to SQL Classes to get a dbml file?
What's next? Generate tables in database? Generate SQL script? Generate cs files? When? How?
The DBML file is not related to the database server at all. It's a completely client side thing. It's essentially a set of information about your tables in the database and how you're going to map them to .NET objects.
Of course, you can drag a table from a database and have Visual Studio infer some information for you automatically, but changing the file will not affect the database. You can create a DBML file from scratch without any database too.
Internally, the DBML file is simply an XML file that's fed into a custom tool by Visual Studio and generates .cs files representing the LINQ object model for your database from it.
The DBML file is mapping that defines your classes based on your database schema. Yes, it defines your (default) connection string, but it doesn't "configure" your database at all.
Linq to Sql uses a database-first approach where you have the database and model your classes after the DB schema. By dragging & dropping the table onto there, you'll be automating the creation of the classes so you don't have to type them out. You can change property names etc from there and the mapping between the property and its correct database column name will remain intact.
this link learn how to create dbml File in your Project :
http://dotnetlearners.com/linq/linq-to-sql-creating-dbml-file
Implement LINQ to SQL first we have to create the DBML file, the DBML file contains the C# source code which allow us to write the LINQ Queries to SQL. Here is the step by step process to generate dbml file.
Right click on the project (or project folder) and select the option Add New Item.
add-new-item
Select LINQ to SQL Classes Template and Give Name as MyDB.dbml.
linq-to-sql-classess
Click on Yes when the below confirmation displayed.
dialog
MyDB.dbml file will be added under App_Code folder.
dbml
Expand Server Explorer and Right click on the Data Connections and select the option Add Connection.
add-connection
Add Connection Pop up will be opened, give the SQL Server details and select the then click on OK button.
server-detail
Database will be added under Data Connections as shown below.
server-explorer
Drag the table in the left pane and if primary key & foreign key relations are there then it will automatically show as shown below.
drag-tables
Drag the stored procedures to the right pane.
drag-store-procedures
Related C# code will be automatically generated and we can see by opening the file MyDB.designer.cs.
dbml-designer-cs
Yes, the DBML file is created when you add a Linq to SQL class. In the designer (what you see when you double click the DBML file) you can drag tables (from the server explorer) onto it. You can then reference these tables in your code. There are more than a few getting started tutorials out there:
Check this SO question for details:
https://stackoverflow.com/questions/481244/can-anyone-recommend-a-good-tutorial-for-learning-linq2sql
Walkthrough: Simple Object Model and Query (C#)
Consider SqlMetal
PK :-)