BlazorSQLite在上线服务器上不能反映
创始人
2024-12-21 18:30:18
0
  1. 确保SQLite数据库文件已正确部署到web服务器的正确位置。
  2. 在项目中添加SQLite包NuGet包。
  3. 使用SQLiteConnectionStringBuilder创建与SQLite数据库的连接字符串。
using Microsoft.Data.Sqlite;

public class SqliteService
{
    private readonly SqliteConnection _connection;

    public SqliteService(string connectionString)
    {
        var connectionStringBuilder = new SqliteConnectionStringBuilder(connectionString);
        _connection = new SqliteConnection(connectionStringBuilder.ConnectionString);
    }

    public void Open() => _connection.Open();

    public void Close() => _connection.Close();

    public void ExecuteSqlCommand(string commandText)
    {
        var command = _connection.CreateCommand();
        command.CommandText = commandText;
        command.ExecuteNonQuery();
    }
}

//在页面中创建sqlite服务的实例,在需要的时候打开并关闭连接,调用ExecuteSqlCommand执行命令。

@page "/"

@inject SqliteService SqliteService




@code {
    private void AddData()
    {
        SqliteService.Open();

        SqliteService.ExecuteSqlCommand("INSERT INTO MyTable (Column1, Column2) VALUES ('Value1', 'Value2')");

        SqliteService.Close();
    }
}

相关内容

热门资讯

热点推荐!智星德州插件2024... 热点推荐!智星德州插件2024最新版,hhpoker作弊实战视频,2025新版教程(有挂神器)1、点...
免费测试版!hhpoker德州... 免费测试版!hhpoker德州透视挂,wejoker辅助机器人,德州论坛(有挂技巧)1、很好的工具软...
重大推荐!wepoker插件程... 重大推荐!wepoker插件程序激活码,模拟器打开hhpoker,必赢教程(有挂方法)1、很好的工具...
实测分享!wepoker底牌透... 1、实测分享!wepoker底牌透视,德普之星辅助工具如何打开,解说技巧(有挂神器)2、进入游戏-大...
重磅来袭!佛手在线有挂吗,wp... 1、重磅来袭!佛手在线有挂吗,wpk透视工作室,2025版教程(有挂透明)。2、佛手在线有挂吗透视辅...
热门推荐!wpk辅助器,德州透... 热门推荐!wpk辅助器,德州透视插件,教你教程(有挂攻略);1分钟了解详细教程(微信 1367043...
最新通报!德扑HHpoker有... 1、最新通报!德扑HHpoker有挂吗,约局吧辅助器,介绍教程(有挂透明)2、进入游戏-大厅左侧-新...
分享实测!we-poker是什... 分享实测!we-poker是什么软件,aapoker辅助器是真的吗,揭秘攻略(有挂透视)1、玩家可以...
记者发布!拱趴大菠萝自动计算机... 您好,拱趴大菠萝自动计算机器人这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很...
分享认知!uupoker有透视... 这是一款非常优秀的wepoker模拟器哪个 ia辅助检测软件,能够让你了解到wepoker模拟器哪个...