有沒有遇到過這種年齡,當我搜索我找不到解決方案。我認爲它被稱爲SQL重載。基本上,當我有「」(一個空字符串)的SQL中的任何參數,我不想在數據庫中設置一個值...我該如何解決這個常見的SQL問題
注意:我想要在SQL級別做它不做在C#級別,因爲它的馬虎這樣。
string Sql = "IF NOT EXISTS (SELECT * FROM tbl_FileSystemReferences) "
+ "INSERT INTO tbl_FileSystemReferences (UploadDir) VALUES (null) "
+ "UPDATE tbl_FileSystemReferences SET "
+ "[email protected], "
+ "[email protected], "
+ "[email protected], "
+ "[email protected], "
+ "[email protected], "
+ "[email protected], "
+ "[email protected], "
+ "[email protected], "
+ "[email protected], "
+ "[email protected] ";
SqlCommand Command = new SqlCommand(Sql);
Command.Parameters.AddWithValue("@UploadDir", f.UploadDir);
Command.Parameters.AddWithValue("@ThumbnailDir", f.ThumbnailDir);
Command.Parameters.AddWithValue("@ArchiveDir", f.ArchiveDir);
Command.Parameters.AddWithValue("@RealDir", f.RealDir);
Command.Parameters.AddWithValue("@FlashDir", f.FlashDir);
Command.Parameters.AddWithValue("@AssociatedFilesDir", f.AssociatedFilesDir);
Command.Parameters.AddWithValue("@EnableArchiving", f.EnableArchiving);
Command.Parameters.AddWithValue("@AppWideDir", f.AppWideDir);
Command.Parameters.AddWithValue("@FFmpegDir", f.FFmpegDir);
Command.Parameters.AddWithValue("@InstallationDir", f.InstallationDir);
ExecuteNonQuery(Command);
我知道有一種方法我用存儲過程來做到這一點我只是不能記得(我認爲這就是所謂的超載)....
乾杯,
不是我們真正使用內聯SQL與參數SQL是對我們來說太過於矯枉過正。我明白你的意思,儘管它很有用。 – Exitos 2011-04-05 08:32:49