Sqlite For .Net
发布时间:2020-12-12 20:38:39 所属栏目:百科 来源:网络整理
导读:DbProviderFactory fact = DbProviderFactories.GetFactory("System.Data.SQLite"); using (DbConnection conn = fact.CreateConnection()) { conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["sqliteConnString"].Co
DbProviderFactory fact = DbProviderFactories.GetFactory("System.Data.SQLite"); using (DbConnection conn = fact.CreateConnection()) { conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["sqliteConnString"].ConnectionString; conn.Open(); DbCommand comm = conn.CreateCommand(); comm.CommandText = "select * from role"; comm.CommandType = CommandType.Text; using (IDataReader reader = comm.ExecuteReader()) { while (reader.Read()) { Response.Write(reader["rName"]); } } } <connectionStrings> <add name="sqliteConnString" connectionString="Data Source=C:ys_sqlite.db3;Pooling=true;FailIfMissing=false" providerName="System.Data.SQLite" /> </connectionStrings> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> <requiredRuntime version="v4.0.20506" /> </startup>
App.config or web.config 中,针对.net 不同版本需要加上! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |