簡體   English   中英

粘貼較大的多行字符串(大約1500行)后,Visual Studio 2010崩潰

[英]Visual Studio 2010 Crashes after pasting a large multi-line string (Approximately 1500 lines)

我正在Visual Studio 2010中創建一個VB應用程序,該應用程序安裝了一些SQL存儲過程。 這些存儲過程是經過加密的,否則我將向我的客戶端提供.sql文件以創建存儲過程。

用於創建存儲過程的安裝腳本的長度為1500行,並且已按照VS 2010要求使用多行文字的方式進行了格式化:

"First Line" & _  
"Second Line" & _  
"etc..."

每當我將多行腳本粘貼到Visual Studio中時,應用程序就會崩潰。 任何人都有更好的方法將非常大的字符串文字分配給字符串變量。 我需要的是以下內容:

Imports System.Data.Sql Client

...

cmd cmd as SqlCommand
dim str as string

str = _
    "Very" & _
    "Long" & _
    ... 1500 lines ...
    "String"

cmd.CommandText = str

或以其他方式將.sql腳本分配給SqlCommand。

謝謝。

可以將其粘貼到記事本中並保存在其中,也可以將其拆分為多個字符串,然后將它們串聯在一起。

甚至更好的是,將命令放在資源文件中並在運行時加載資源!

我也遇到了這個問題,以下代碼對我有用:

cmd cmd as SqlCommand
dim str as string

str = "Very" 
str &= "Long" 
    ... 1500 lines ...
str &= "String"

cmd.CommandText = str

希望對您有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM