作者:觉悟 | 来源:互联网 | 2023-05-18 01:07
web.config
public class ProductService
{
public static readonly ProductService Instance = new ProductService();
private static string cOnnstr= ConfigurationManager.ConnectionStrings["SQLiteDB"].ConnectionString;
public DataTable GetData()
{
SQLiteConnection cOnn= null;
int num = 0;
int productNum = 10;
try
{
cOnn= new SQLiteConnection(connstr);
conn.Open();
string sql = "select * from users";
//SQLiteParameter[] parameter = { new SQLiteParameter("@product", product), new SQLiteParameter("@productNum", productNum) };
SQLiteCommand cmd = new SQLiteCommand(sql, conn);
//cmd.Parameters.AddRange(parameter);
SQLiteDataAdapter sda = new SQLiteDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
return dt;
}
catch (Exception ex)
{
return null;
}
}
}