计算机目录读取,从项目目录中读取SQL查询文件(Read SQL query file from project directory)...
從項目目錄中讀取SQL查詢文件(Read SQL query file from project directory)
我在Visual Studio項目中放置了3個特別大的SQL查詢,位于項目目錄中的“查詢”文件夾下(不是解決方案)。 有沒有一種雄辯的方式來訪問這些文件? 我希望像@"Queries/firstSqlQuery.sql這樣的東西可行。
指定完整路徑,比如@"C:\\Users\John\Documents\VisualStudio2010\Projects\MySolution\MyProject\Queries\firstSqlQuery.sql是我真的不想做的事情,因為它需要我回到代碼并修復路徑,如果應用程序移動。
編輯:由于某種原因,該頁面正在C:\\Program Files(x86)\Common Files\Microsoft Shared\DevServer\Queries\firstSqlQuery.sql 。 當可執行文件目錄不同時,為什么要查看此位置?
I've put 3 especially large SQL queries within my Visual Studio project, under a folder "Queries" that is in the project directory (not the solution). Is there an eloquent way to access these files? I was hoping that something like @"Queries/firstSqlQuery.sql would work.
Specifying the full path, like with @"C:\\Users\John\Documents\VisualStudio2010\Projects\MySolution\MyProject\Queries\firstSqlQuery.sql is something I'd really rather not do, since it requires me to go back into code and fix the path, should the application move.
EDIT: For some reason, the page is looking for the files in C:\\Program Files(x86)\Common Files\Microsoft Shared\DevServer\Queries\firstSqlQuery.sql. Why is it looking in this location, when the executable directory is different?
原文:https://stackoverflow.com/questions/16984269
2019-11-29 16:11
滿意答案
你可以做這樣的事情......如果它在項目之外。 (當我初讀這篇文章時 - 我誤讀并認為它在我假設包含該項目的解決方案目錄中) -
var pathToBin = Assembly.GetExecutingAssembly().Location;
var directoryInfoOfBin = new DirectoryInfo(pathToBin);
var solutionDirectory = directory.Parent().Parent();
var pathToSolution = solutionDirectory.FullName;
但如果它在項目中,這會簡單得多
System.Web.HttpContext.Current.Server.MapPath("~/Queries/firstSqlQuery");
You can do something like this... if it's outside of project. (When I intitially read this-- I misread and thought it was in the solution directory which I was assuming contained the project)--
var pathToBin = Assembly.GetExecutingAssembly().Location;
var directoryInfoOfBin = new DirectoryInfo(pathToBin);
var solutionDirectory = directory.Parent().Parent();
var pathToSolution = solutionDirectory.FullName;
but this is much simpler if it's in the project
System.Web.HttpContext.Current.Server.MapPath("~/Queries/firstSqlQuery");
相關問答
從解決方案資源管理器中,右鍵單擊myfile.txt并選擇“屬性” 從那里,將Build Action設置為content并Copy to Output Directory以使其Copy always Copy if newer或Copy if newer From Solution Explorer, right click on myfile.txt and choose "Properties" From there, set the Build Action to content and ...
請參閱: 支持的.NET Framework庫 仍然可以從托管存儲過程,觸發器,用戶定義函數,用戶定義類型和用戶定義聚合中調用不受支持的庫。 必須首先使用CREATE ASSEMBLY語句在SQL Server數據庫中注冊不受支持的庫,然后才能在代碼中使用它。 應檢查并測試在服務器上注冊和運行的任何不受支持的庫的安全性和可靠性。 例如,不支持System.DirectoryServices命名空間。 您必須先注冊具有UNSAFE權限的System.DirectoryServices.dll程序集,...
你問題中的圖像不是一個項目。 它是SSMS對象資源管理器,是您連接到的數據庫服務器上對象的分層視圖。 SSMS項目的默認位置是C:\Users\\Documents\SQL Server Management Studio 。 The image in your question is not a project. It is SSMS Object Explorer, a hierarchical view of objects on the database server...
嘗試使用動態SQL,因為您在OPENROWSET中使用參數 DECLARE @i int = 1
DECLARE @file AS nvarchar(MAX)
DECLARE @sql VARCHAR(max)
WHILE(@i<=50)
BEGIN
SET @file = 'C:\Users\Barry\Desktop\Output\output' + cast(@i as varchar(2)) + '.txt';
SET @sql = '
INSERT INTO dbo.[...
CLR存儲過程最適合這樣的任務。 MSDN : 創建CLR存儲過程 。 如何 創建和運行CLR SQL Server存儲過程 也看到這個SO答案 ,有一些你需要的代碼。 這個創建一個CLR函數(代碼粘貼在下面)。 public partial class UserDefinedFunctions
{
[SqlFunction(DataAccess = DataAccessKind.Read,
FillRowMethodName = "GetFiles_FillRow", T...
編寫一個CLR storedprocedure(c#),它讀取圖像文件的內容并將其作為varbinary(MAX)返回。 Write a CLR storedprocedure (c#) which reads the contents of the image file and returns it as a varbinary(MAX).
你可以做這樣的事情......如果它在項目之外。 (當我初讀這篇文章時 - 我誤讀并認為它在我假設包含該項目的解決方案目錄中) - var pathToBin = Assembly.GetExecutingAssembly().Location;
var directoryInfoOfBin = new DirectoryInfo(pathToBin);
var solutionDirectory = directory.Parent().Parent();
var pathToSolution ...
您可能想要嘗試的是使用: AssetManager am = getAssets();
InputStream is;
is = am.open(pathToFile.txt);
然后使用byte []緩沖區(使用is.available();獲取大小)和is.read(緩沖區)讀取后不要忘記is.close()。 如果您不在Activity中,則必須使用context.getAssets()才能獲取AssetManager。 希望對你有所幫助。 What you might want to t...
我們首先開始調試文件路徑問題。 你可以在這里使用兩件事。 function db_data() {
WP_Filesystem();
global $wp_filesystem;
global $wpdb;
echo 'Current Path is '. __DIR__;
$file = __DIR__."/sql/my_insert_query.sql";
if(!is_readable($file)) {
echo 'File...
如果你使用this.class().getClassLoader().getResourceAsStream("/res/xxx") ,它將嘗試從類路徑加載資源。 如果您不希望這樣做,則需要指定絕對路徑。 Classpath上的資源 如果您不希望將資源內置到JAR中,我建議在src/main/resources目錄下使用不同的maven項目。 這將創建一個包含文件的jar文件,大小約為500MB。 在此之后,您可以在包含應用程序代碼的項目中包含此項目的依賴項。 然后,這將能夠使用getResour...
相關文章
出現bad interpreter:No such file or directory的原因 是文件格
...
Hi Pythonistas! 測試和調試 Testing & Debuggi
...
這個是因為本地沒有安裝php-solr的擴展導致的,安裝方法(使用的是ubuntu) cd /opt
...
查詢一個對象(實體類必須有一個不帶參數的構造方法),使用select查詢,基于投影的查詢,通過在列表中
...
用source c:\xxx.sql,出現Ignoring query to other databa
...
Java 流(Stream)、文件(File)和IO Java.io包幾乎包含了所有操作輸入、輸
...
有表格如下: t_table 8 想得到這樣的結果:(只取有重復的第一個,相同的排除,例如f) 1 a
...
數據庫表A 有個字段a是int類型 a中有數據有1到9任意(有重復的) 想取得a中,當 a=1時
...
Solr1.4 Both delete by id and delete by query can b
...
查詢操作符(Query Operators)可以讓我們寫出復雜查詢條件,讓我們使用的過程更加靈活。官方
...
最新問答
找到了完全相同的東西: http : //www.dragonbyte-tech.com/product/40-vbcredits-ii-deluxe/ Found something that does exact same thing: http://www.dragonbyte-tech.com/product/40-vbcredits-ii-deluxe/
不知道任何可以實際切換的調試器,但您可以將兩個調試器連接到您的進程。 在調試模式下在Java IDE中啟動Java程序會附加Java調試器。 然后打開用于CPP代碼的IDE,并將其調試器附加到正在運行的Java進程。 在Visual Studio中,這將是Debug -> Attach to Process... 您將看到一個包含進程列表的對話框。 在這里選擇您的Java進程。 如果Visual Studio無法正確檢測到,您可能必須將列表上方的字段切換為“本機代碼”。 在CPP代碼中設置適當的
您需要使用ajax發送該變量。 $.get('your.jsp', {data: $('#'+this.id+'t').val()}, function(response) { console.log(response); }); You need to send that variable using ajax. $.get('your.jsp', {data: $('#'+this.id+'t').val()}, function(response) { console.l
確保已設置root密碼(sudo su passwd)根據ssh的安裝方式,通常需要編輯/ etc / ssh / sshd_config并將“PermitRootLogin no”更改為“PermitRootLogin yes” Make sure you have set a root password (sudo su passwd) Depending how your ssh is installed, you usually need to edit /etc/ssh/sshd_co
看看FMDB的用法 。 [db executeUpdate:@"INSERT INTO notes VALUES (?,?,?)", title, comment, [NSNumber numberWithInt:fkID]]; 提供給-executeUpdate:方法的所有參數(或接受va_list作為參數的任何變體)都必須是對象。 Here is what I ended up doing. NSString *sql = [NSString stringWithFormat:
我后來發現這是一個與多德興相關的問題。 我需要運行一個腳本來為我的main-dex-list生成文件的名稱 下面的博客文章詳細介紹了這一點: http : //blog.osom.info/2014/10/generating-main-dex-list-file.html I later found out that this was an issue relating to multi dexing. I needed to run a script to generate the name
使用OAuth 2.0,您可以使用可擴展的標準和基于令牌的身份驗證,使用戶可以撤消身份驗證票證,例如,如果他們的手機被盜。 OAuth 2.0支持各種授權類型。 那些來自facebook和twitter登錄的人可以概括為“3-legged oauth”,但是對于2-legged OAuth,還有兩種授權類型,特別是資源所有者密碼憑證授權 (頁面末尾的第4.3節),這將是只需交換身份驗證令牌的用戶名和密碼即可。 如果你不愿意,就沒有必要實施三條腿的oauth。 對于大多數用例,我建議在基于加密的自
您應該將此作為多個連接進行處理。 特別是,您需要為電子郵件的“從”和“到”部分單獨加入: SELECT e.EmailID as id, e.DateStamp as timed, edfrom.profileid as sender, edto.profileid as receiver FROM EmailDirection edfrom join Email e on edfrom.emailid = e.emailid and ed.direction
問題根本不是ngZone 。 事實上,您正在使用更改this值的常規函數。 所以this.distance內的this.distance距離function(response,status)是不同的。 嘗試: (response, status)=> { if (status === 'OK') { directionsDisplay.setDirections(response); var total = 0; var rou
總結
以上是生活随笔為你收集整理的计算机目录读取,从项目目录中读取SQL查询文件(Read SQL query file from project directory)...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 限招2019应届计算机毕业生,2019年
- 下一篇: 计算机死机的重启方法,使用“紧急重启”功