Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create a SQL Server view but within VB.Net code to be used for a query with my VB application. What is the best way to do this. I have the connection etc, just need the syntax if it can be done.
Posted

1 solution

you create a string like the following
dim <code>createstring as string
 createstring="USE [DatabaseName]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[viewName]
AS
********Put your sql select statement here********
GO"


dim sqlcmd as sqlcommand</code>


        sqlcmd=new sqlcommand(createstring,youropenconnection)
        sqlcmd.CommandType = CommandType.Text
        sqlcmd.ExecuteNonQuery()


This should do the job I think


Schenck
 
Share this answer
 
v2
Comments
Central_IT 30-Jan-14 11:05am    
Works a treat. Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900