How can I create a view in a SQL Server database with C#?

How do I create a view dynamically in SQL Server using C#?

Answers


Something like this, obviously your connection code will be different (better):

SqlConnection conn = null;
conn = new SqlConnection("yourConnectionString");
conn.Open();
string strSQLCommand = "CREATE VIEW vw_YourView AS SELECT YOurColumn FROM YourTable";
SqlCommand command = new SqlCommand(strSQLCommand, conn); 
string returnvalue = (string)command.ExecuteScalar(); 
conn.Close();

Need Your Help

Pass object that contains objects to Activity via Intent

android android-intent parcelable

I have an Object that I need to pass via the Intent to another Activity via the onclick method.

Contol Position Not updating after moving it in runtime

c# wpf-controls

I have an application where need to dynamically create and move textblocks around in a canvas later save the layout and the load the layout.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.