view
-
i am working on a project to automatically generate view if the user select certain number of tables. my problem is how can i save the query generated as a view
-
i am working on a project to automatically generate view if the user select certain number of tables. my problem is how can i save the query generated as a view
create an execute non query and create a view. CREATE VIEW dbo.vw_myview AS SELECT * from mytable
-
create an execute non query and create a view. CREATE VIEW dbo.vw_myview AS SELECT * from mytable
i understand your anwser but my question is this the query is autogenerated in a form of string in a text box so how can i pass the string query and save it as a view using sqldmo
-
i understand your anwser but my question is this the query is autogenerated in a form of string in a text box so how can i pass the string query and save it as a view using sqldmo
Try something like this You will have to fill in the blanks for connections string etc.. Before some pipes up with "injection attacks security risks etc..." This is a very basic code to give an idea of how it could work. ========================= string MySQL = TextBox1.Text; // SQL in the view select * from table string MyViewName = TextBox2.Text; // The view name on DB SQLstring = "CREATE VIEW " + MyViewName + " AS " + MySQL SqlConnection myConnection = new SqlConnection(strConnectSQL); SqlCommand myCommand = new SqlCommand( SQLstring, myConnection ); try { myConnection.Open(); myCommand.ExecuteScalar(); myConnection.Close(); } catch { myConnection.Close(); }