在VB.Net代码中创建SQL SERVER视图 [英] Create a SQL SERVER view within VB.Net code

查看:215
本文介绍了在VB.Net代码中创建SQL SERVER视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在VB.Net代码中创建一个SQL Server视图,用于我的VB应用程序的查询。做这个的最好方式是什么。我有连接等,只需要语法就可以了。

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.

推荐答案

你创建一个如下字符串

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()





这应该可以完成我认为的工作





Schenck



This should do the job I think


Schenck


这篇关于在VB.Net代码中创建SQL SERVER视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆