Bonjour,
Windows 2000 Pro
J'utilise la librairie :ADO.NET 2.0 Provider for SQLite
C# 2005 Express
SQLite
Quelle est la commande pour insérer le contenu d'un TextBox dans un BLOB ?
Je précise que mon TextBox est bien-sur multilignes.
Merci.
Tintin92
Version imprimable
Bonjour,
Windows 2000 Pro
J'utilise la librairie :ADO.NET 2.0 Provider for SQLite
C# 2005 Express
SQLite
Quelle est la commande pour insérer le contenu d'un TextBox dans un BLOB ?
Je précise que mon TextBox est bien-sur multilignes.
Merci.
Tintin92
Je me réponds.
Il n'est pas nécessaire d'utiliser un BLOB pour sauvegarder le contenu d'un TextBox, un string suffit.
Code:
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 private void btInsertBLOB2_Click(object sender, EventArgs e) { try { using (DbConnection cnn = new SQLiteConnection("Data Source=DBLines.db3")) using (DbCommand cmd = cnn.CreateCommand()) { cmd.CommandText = "INSERT INTO TableLines (LineName, PointPairsList) VALUES('Roger', @str )"; DbParameter PointPairsList = cmd.CreateParameter(); PointPairsList.ParameterName = "@str"; PointPairsList.Value = textBox1.Text; cmd.Parameters.Add(PointPairsList); cnn.Open(); cmd.ExecuteNonQuery(); } } catch (Exception exc) { MessageBox.Show(exc.Message); } } private void btReadBLOB_Click(object sender, EventArgs e) { try { using (DbConnection cnn = new SQLiteConnection("Data Source=DBLines.db3")) using (DbCommand cmd = cnn.CreateCommand()) { cmd.CommandText = "SELECT PointPairsList FROM TableLines WHERE PointPairsList IS NOT NULL"; cnn.Open(); using (DbDataReader rd = cmd.ExecuteReader()) { if (rd.Read() == false) throw new ArgumentOutOfRangeException(); textBox1.Text = rd.GetString(0); } } } catch (Exception exc) { MessageBox.Show(exc.Message); } } }