C#asp.net 连接使用sqlite 数据库的代码怎么写

2024-11-25 15:44:48
推荐回答(1个)
回答1:

引用命名空间
using System.Data;
using System.Data.SqlClient;

//1.连接

string connString = "Data Source=.;Database=db_BBS;Integrated Security=True;";
SqlConnection conn = new SqlConnection(connString);
try
{
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
}
catch (Exception ex)
{
throw;//来抛出发生异常的根本来源
}
finally
{
conn.Close();
}