C# sqlite数据库操作类,可建立sqliteConnection 数据库连接、Query数据库、执行ExcDbCommand sql命令,以及sqliteParameter[] 、ExecuteReader()、ExecuteNonQuery()、sqliteDataAdapter等操作。
02
|
System.Collections.Generic;
|
08
namespace DBHelper.sqlite
|
10
public class sqliteHelper
|
11
|
12
|
static string _connectionString = ConfigurationManager.ConnectionStrings[ "ConnectionString" ].ConnectionString;
|
13
|
sqliteConnection _connection;
|
14
|
16
{
|
17
|
_connection = new sqliteConnection(_connectionString);
|
18
}
|
19
|
sqliteHelper(connectionString)
|
20
:this ()
|
21
|
22
|
_connectionString = connectionString;
|
26
27
|
if (_connection.State != ConnectionState.Open)
|
31
|
32
|
(_connection.State != ConnectionState.Closed)
|
34
35
|
|
37
|
38
|
return Query(sql, null );
|
39
|
40
|
41
|
sql,153)!important; background:none!important">params sqliteParameter[] parameters)
|
42
43
|
|
44
sqliteCommand command = ExcDbCommand(sql,parameters);
|
45
|
DataSet ds = DataSet();
|
46
sqliteDataAdapter da = sqliteDataAdapter(command);
|
48
//this.Close();
|
50
51
|
52
|
bool Exc( 53
|
54
|
Exc(sql,monospace!important; font-size:10pt!important; min-height:auto!important; display:block!important; background:none!important">55
|
56
|
sqliteParameter[] parameters)
|
60
int result = command.ExecuteNonQuery();
|
62
result > 0;
|
63
|
64
|
sqliteDataReader Read(65
|
66
|
Read(sql,monospace!important; font-size:10pt!important; min-height:auto!important; display:block!important; background:none!important">67
|
68
|
69
|
70
|
71
|
72
|
sqliteDataReader reader = command.ExecuteReader();
|
74
reader;
|
75
|
76
|
sqliteCommand ExcDbCommand(ottom:auto!important; height:auto!important; width:auto!important; line-height:1.1em!important; font-family:Consolas,sqliteParameter[] parameters)
|
77
|
78
|
sqliteCommand command = sqliteCommand(sql,_connection);
|
79
|
command.CommandType = CommandType.Text;
|
80
(parameters == null || parameters.Length == 0)
|
85
|
command.Parameters.Add(param);
|
86
87
|
88
|
89
|
90
|
}
|
以上文件可保存文件名为:sqliteHelper.cs
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。