2024年5月28日发(作者:)
///
public class SQLiteHelper
{
///
/// Creates a new
///
private SQLiteHelper()
{
}
///
/// Creates the command.
///
/// Connection.
/// Command text.
/// Command parameters.
///
public static SQLiteCommand CreateCommand(SQLiteConnection connection, string commandText, params SQLiteParameter[] commandParameters)
{
SQLiteCommand cmd = new SQLiteCommand(commandText, connection);
if ( > 0)
{
foreach (SQLiteParameter parm in commandParameters)
(parm);
}
return cmd;
}
///
/// Creates the command.
///
/// Connection string.
/// Command text.
/// Command parameters.
///
public static SQLiteCommand CreateCommand(string connectionString, string commandText, params SQLiteParameter[] commandParameters)
{
SQLiteConnection cn = new SQLiteConnection(connectionString);
SQLiteCommand cmd = new SQLiteCommand(commandText, cn);
if ( > 0)
{
foreach (SQLiteParameter parm in commandParameters)
(parm);
}
return cmd;
}
///
/// Creates the parameter.
///
/// Name of the parameter.
/// Parameter type.
/// Parameter value.
///
public static SQLiteParameter CreateParameter(string parameterName, parameterType, object parameterValue)
{
SQLiteParameter parameter = new SQLiteParameter();
= parameterType;
terName = parameterName;
= parameterValue;
return parameter;
}
///
/// Shortcut method to execute dataset from SQL Statement and object[] arrray of parameter values
///
/// SQLite Connection string
/// SQL Statement with embedded "@param" style parameter names
/// object[] array of parameter values
///
public static DataSet ExecuteDataSet(string connectionString, string commandText, object[] paramList)
{
SQLiteConnection cn = new SQLiteConnection(connectionString);
SQLiteCommand cmd = Command();
dText = commandText;
if (paramList != null)
{
AttachParameters(cmd,commandText, paramList);
}
DataSet ds = new DataSet();
if ( == )
();
SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
(ds);
e();
e();
();
return ds;
}
///
/// Shortcut method to execute dataset from SQL Statement and object[] arrray of parameter values
///
/// Connection.
/// Command text.
/// Param list.
///
public static DataSet ExecuteDataSet(SQLiteConnection cn, string commandText, object[] paramList)
{
SQLiteCommand cmd = Command();
dText = commandText;
if (paramList != null)
{
AttachParameters(cmd,commandText, paramList);
}
DataSet ds = new DataSet();
if ( == )
();
SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
(ds);


发布评论