-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatabaseSample.cs
72 lines (64 loc) · 2.29 KB
/
DatabaseSample.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Reflection;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SQLite;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI.Selection;
namespace TestWorks
{
[Transaction(TransactionMode.Manual)]
class DatabaseSample //: IExternalCommand
{
//public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
//{
// UIApplication uiapp = commandData.Application;
// UIDocument uidoc = uiapp.ActiveUIDocument;
// Application app = uiapp.Application;
// Document doc = uidoc.Document;
// return Result.Succeeded;
//}
public SQLiteConnection myConnection;
//string dataFile = @"URI=file:C:\Users\MILA\source\repos\SQLiteLesson\Resources\OurDataBase4C.db";
public DatabaseSample()
{
//myConnection = new SQLiteConnection("Data Source=C:/OurDataBase.db; Version=3;");
//myConnection = new SQLiteConnection("Data Source=C:/Users/MILA/PycharmProjects/pythonProject2/OurDataBase.db; Version=3;");
myConnection = new SQLiteConnection("Data Source=C:/Users/MILA/source/repos/TestWorks/Resources/OurDataBase4C.db; Version=3;");
if (myConnection != null)
{
string information = "my connection is not NULL";
TaskDialog.Show("Connection State", information);
}
else
{
string information2 = "my connection is NULL";
TaskDialog.Show("Connection Error", information2);
}
//if (File.Exists("./OurDataBase.db"))
//{
// Console.WriteLine("Database file found");
//}
}
public void OpenConnection()
{
if (myConnection.State != System.Data.ConnectionState.Open)
{
myConnection.Open();
}
}
public void CloseConnection()
{
if (myConnection.State != System.Data.ConnectionState.Closed)
{
myConnection.Close();
}
}
}
}