質問編集履歴
1
ソース全文です
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,87 @@
|
|
18
18
|
|
19
19
|
```ここに言語を入力
|
20
20
|
|
21
|
+
Imports System.Data.SQLite
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Public Class Form1
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
''' <summary>
|
30
|
+
|
31
|
+
''' データベース作成ボタンクリック
|
32
|
+
|
33
|
+
''' </summary>
|
34
|
+
|
35
|
+
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
36
|
+
|
37
|
+
Try
|
38
|
+
|
39
|
+
Using con As New SQLiteConnection("Data Source=sample.db")
|
40
|
+
|
41
|
+
con.Open()
|
42
|
+
|
43
|
+
Using cmd As SQLiteCommand = con.CreateCommand()
|
44
|
+
|
45
|
+
cmd.CommandText = "CREATE TABLE Sample (ID INTEGER PRIMARY KEY, Name NVARCHAR(128), Age INTEGER)"
|
46
|
+
|
47
|
+
cmd.ExecuteNonQuery()
|
48
|
+
|
49
|
+
cmd.CommandText = "INSERT INTO Sample (Name, Age) VALUES('一郎', 10)"
|
50
|
+
|
51
|
+
cmd.ExecuteNonQuery()
|
52
|
+
|
53
|
+
cmd.CommandText = "INSERT INTO Sample (Name, Age) VALUES('二郎', 20)"
|
54
|
+
|
55
|
+
cmd.ExecuteNonQuery()
|
56
|
+
|
57
|
+
cmd.CommandText = "INSERT INTO Sample (Name, Age) VALUES('三郎', 30)"
|
58
|
+
|
59
|
+
cmd.ExecuteNonQuery()
|
60
|
+
|
61
|
+
End Using
|
62
|
+
|
63
|
+
End Using
|
64
|
+
|
65
|
+
MessageBox.Show("Sampleデータベース作成成功", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
|
66
|
+
|
67
|
+
Catch ex As Exception
|
68
|
+
|
69
|
+
MessageBox.Show("Sampleデータベース作成失敗" + Environment.NewLine + ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
|
70
|
+
|
71
|
+
End Try
|
72
|
+
|
73
|
+
End Sub
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
''' <summary>
|
78
|
+
|
79
|
+
''' 検索ボタンクリック
|
80
|
+
|
81
|
+
''' </summary>
|
82
|
+
|
83
|
+
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
84
|
+
|
85
|
+
Using con As New SQLiteConnection("Data Source=sample.db")
|
86
|
+
|
87
|
+
Dim ds As New DataSet
|
88
|
+
|
89
|
+
Dim da As New SQLiteDataAdapter("SELECT * FROM Sample", con)
|
90
|
+
|
91
|
+
da.Fill(ds, "Sample")
|
92
|
+
|
93
|
+
Me.DataGridView1.DataSource = ds.Tables("Sample")
|
94
|
+
|
95
|
+
End Using
|
96
|
+
|
97
|
+
End Sub
|
98
|
+
|
99
|
+
|
100
|
+
|
21
|
-
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
|
101
|
+
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
|
22
102
|
|
23
103
|
Using con As New SQLiteConnection("Data Source=sample.db")
|
24
104
|
|
@@ -33,6 +113,10 @@
|
|
33
113
|
End Using
|
34
114
|
|
35
115
|
End Sub
|
116
|
+
|
117
|
+
End Class
|
118
|
+
|
119
|
+
|
36
120
|
|
37
121
|
```
|
38
122
|
|