有没有遇到过这种年龄,当我搜索我找不到解决方案。我认为它被称为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