FAQ/DeleteReportSet.md
... ...
@@ -12,33 +12,73 @@ If you have overwritten [SaveReportSet()](http://wiki.izenda.us/FAQ/SaveReportSe
12 12
##Examples
13 13
The code samples below demonstrate method of overriding the method to implement custom functionality using both [[DatabaseAdHocConfig|http://wiki.izenda.us/FAQ/Storing-Reports#Database-Mode]] and [[FileSystemAdHocConfig|http://wiki.izenda.us/FAQ/Storing-Reports#File-System-Mode]].
14 14
15
-###DatabaseAdHocConfig Sample
15
+### C# DatabaseAdHocConfig Sample
16 16
17 17
```csharp
18
-/* BEGIN Database Mode Code Sample */
19
-public override void DeleteReportSet() {
20
- string sql = string.Format(@"DELETE FROM {1} WHERE Name='{0}'", reportName.Trim(), SavedReportsTable);
21
- System.Data.IDbCommand command = Izenda.AdHoc.AdHocContext.Driver.CreateCommand(sql);
22
- try
18
+public override void DeleteReportSet(string reportName)
23 19
{
24
- command.ExecuteNonQuery();
20
+ try
21
+ {
22
+ string connectionString = @"Persist Security Info=False;Initial Catalog=Northwind;Data Source=LESHA-PC\SQL2012;User ID=dataLogin;Password=dataPassword;Integrated Security=false;";
23
+ string sql = string.Format(@"DELETE FROM {1} WHERE Name='{0}'", reportName.Trim(), AdHocSettings.SavedReportsTable);
24
+ using (System.Data.IDbConnection connection = new System.Data.SqlClient.SqlConnection(connectionString))
25
+ {
26
+ connection.Open();
27
+ using (System.Data.IDbCommand command = connection.CreateCommand())
28
+ {
29
+ command.CommandText = sql;
30
+ command.ExecuteNonQuery();
31
+ }
32
+ }
33
+ }
34
+ catch
35
+ {
36
+ }
25 37
}
26
- finally
38
+```
39
+
40
+### C# FileSystemAdHocConfig Sample
41
+
42
+```csharp
43
+public override void DeleteReportSet(string reportName)
27 44
{
28
- if (command.Connection.State == System.Data.ConnectionState.Open)
29
- command.Connection.Close();
45
+ try
46
+ {
47
+ string filePath = System.IO.Path.Combine(ReportPath, reportName);
48
+ System.IO.File.Delete(filePath + ".xml");
49
+ }
50
+ catch
51
+ {
52
+ }
30 53
}
31
-}
32
-/* END Database Mode Code Sample */
33 54
```
34 55
35
-###FileSystemAdHocConfig Sample
56
+### VB.NET DatabaseAdHocConfig Sample
57
+```visualbasic
58
+Public Overrides Sub DeleteReportSet(reportName As String)
59
+ Try
60
+ Dim connectionString As String = "Persist Security Info=False;Initial Catalog=Northwind;Data Source=LESHA-PC\SQL2012;User ID=dataLogin;Password=dataPassword;Integrated Security=false;"
61
+ Dim sql As String = String.Format("DELETE FROM {1} WHERE Name='{0}'", reportName.Trim(), AdHocSettings.SavedReportsTable)
62
+ Using connection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
63
+ connection.Open()
64
+ Using command As System.Data.IDbCommand = connection.CreateCommand()
65
+ command.CommandText = sql
66
+ command.ExecuteNonQuery()
67
+ End Using
68
+ End Using
69
+ Catch ex As Exception
70
+ End Try
71
+ End Sub
72
+```
73
+
74
+### VB.NET FileSystemAdHocConfig Sample
75
+```visualbasic
76
+Public Overrides Sub DeleteReportSet(reportName As String)
77
+ Try
78
+ Dim filePath As String = System.IO.Path.Combine(ReportPath, reportName)
79
+ System.IO.File.Delete(filePath + ".xml")
80
+ Catch ex As Exception
81
+ End Try
82
+ End Sub
83
+```
36 84
37
-```csharp
38
-/* BEGIN Filesystem Mode Code Sample */
39
-public override void DeleteReportSet() {
40
- string filePath = Path.Combine(ReportPath, reportName);
41
- File.Delete(filePath + ".xml");
42
-}
43
-/* END Filesystem Mode Code Sample */
44
-```
... ...
\ No newline at end of file