VS2013 使用localDB快速搭建数据库开发环境

1. LocalDB是啥

听名取义,localDB即本地数据库,大伙都知道VS和SQL Server都是微软自家的东西,既然有了SQL Server了,还搞啥localDB。

作为一个程序猿来说,开发的电脑务必要极速,否则严重影响开发体验,进而影响灵感,进而影响工作效率,进而影响薪资,进而影响家庭关系…扯远了,总之要快,天下武功,唯快不破…SQL Server显然不符合这一点,装了这玩意占空间不说,跑起来还很慢,简直不能忍。

所以localDB其实就是一个开发者版的SQL Server,速度快、无需管理,就是这么爽快。

2. 如何安装

VS2013自带(其他版本VS应该大多也有,但是我也没有都试试),当然安装VS的时候该选的安装项都得选上哈。

3. 创建数据库

打开VS,依次点击视图-服务器资源管理器-右击数据连接-创建新SQL Server数据库,打开如下图窗口:
如图设置即可。
这里写图片描述

点击确定后,会发现服务器资源管理器里面多了个数据库:
这里写图片描述

4. 数据库连接字符串怎么写

哈哈,很多程序猿同志就纠结了,这种的,咋写数据库连接字符串呢,其实很简单啊,右键点击该连接,属性里面就有哈:
这里写图片描述

具体是这样的:

Data Source=(LocalDB)\v11.0;Initial Catalog=TestDatabase;Integrated Security=True;Pooling=False

哈哈,这下子,开发可爽了,又快又干净,可别傻乎乎的非得装个大而笨的SQL Server了


如有问题请扫码联系我
在这里插入图片描述

已标记关键词 清除标记
VB 写入sqlite 数据库太慢,写入50个数据需要4秒,100个数据需要8秒,请哪位大侠帮我看一下程序哪里不对(程序能够正常运行,用excel vba 写入access不到1秒就完成了),非常感谢! Private Sub CommandButton1_Click() timer11 = Now() Dim m As Integer, t As Integer Dim SQL As String, SQL1 As String, SQL2 As String Dim sr$, i%, xb%, mmmm1$, mmmm2$, mmmm3$, mmmm4$, rightcount%, righttotal%, kkkkk%, testwrong%, wrongcount%, arr0, arr, arr2, arr4, d0, d1, d2, d3, d4, d5, testright%, d8 sr = "" Dim sCnn As cConnection, sRs As cRecordset Set sCnn = New_c.Connection sCnn.OpenDB App.Path & "\Database\database.db" Set sRs = sCnn.OpenRecordset("Select * from cltestlist Where 考试序号<>'" & sr & "'") arr = sRs.GetRows(sRs.RecordCount) Set sRs = sCnn.OpenRecordset("Select * from cldefine") arr0 = sRs.GetRows(sRs.RecordCount) Set d0 = CreateObject("scripting.dictionary") Set d1 = CreateObject("scripting.dictionary") Set d2 = CreateObject("scripting.dictionary") Set d3 = CreateObject("scripting.dictionary") Set d4 = CreateObject("scripting.dictionary") Set d5 = CreateObject("scripting.dictionary") For i = 0 To UBound(arr, 2) d0(Val(arr(9, i))) = Val(arr(5, i)) d1(Val(arr(9, i))) = arr(6, i) d2(Val(arr(9, i))) = (arr(7, i)) d3(Val(arr(9, i))) = (arr(17, i)) d4(Val(arr(9, i))) = (arr(11, i)) d5(Val(arr(9, i))) = (arr(10, i)) Next If IsNull(arr0(2, 14)) = True Or arr0(2, 14) = "" Then For i = 1 To Val(arr0(2, 7)) xb = Val(d0(i)) mmmm = Trim(TextBox1(i)) If SQL = "" Then SQL = "update cltestlist set 当前答题='" & mmmm & "' where 累计序号='" & xb & "'" Else SQL = SQL & ";" & "update cltestlist set 当前答题='" & mmmm & "' where 累计序号='" & xb & "'" End If Next Else For i = 1 To Val(arr0(2, 7)) xb = Val(d0(i + (arr0(2, 6) - 1) * 40)) mmmm = Trim(TextBox1(i)) If SQL = "" Then SQL = "update cltestlist set 当前答题='" & mmmm & "' where 累计序号='" & xb & "'" Else SQL = SQL & ";" & "update cltestlist set 当前答题='" & mmmm & "' where 累计序号='" & xb & "'" End If Next End If SQL1 = "update clTemp2 set 错误题号='" & sr & "'" sCnn.Execute (SQL) sCnn.Execute (SQL1) Set sRs = sCnn.OpenRecordset("Select * from cltestlist Where 考试序号>0") ''''刷计算 arr = sRs.GetRows(sRs.RecordCount) SQL = "" SQL1 = "" For i = 0 To UBound(arr, 2) If arr(17, i) = arr(11, i) And arr(10, i) <> "" Then xb = (arr(5, i)) mmmm1 = rightcount mmmm2 = "正确" mmmm3 = Format(wrongcount / (rightcount + wrongcount), "0.00%") mmmm4 = "" If SQL = "" Then SQL = "update cltestlist set 选中='" & mmmm4 & "', 错误率= '" & mmmm3 & "',最后一次对错='" & mmmm2 & "',正确次数='" & mmmm & "' where 累计序号='" & xb & "'" Else SQL = SQL & ";" & "update cltestlist set 选中='" & mmmm4 & "', 错误率= '" & mmmm3 & "',最后一次对错='" & mmmm2 & "',正确次数='" & mmmm & "' where 累计序号='" & xb & "'" End If ElseIf arr(10, i) <> "" Then xb = Val(arr(5, i)) mmmm4 = wrongcount mmmm3 = "错误" mmmm2 = Format(wrongcount / (rightcount + wrongcount), "0.00%") If SQL = "" Then SQL = "update cltestlist set 错误次数='" & mmmm4 & "', 最后一次对错= '" & mmmm3 & "',错误率='" & mmmm2 & "'where 累计序号='" & xb & "'" Else SQL = SQL & ";" & "update cltestlist set 错误次数='" & mmmm4 & "', 最后一次对错= '" & mmmm3 & "',错误率='" & mmmm2 & "'where 累计序号='" & xb & "'" End If End If Next For i = 1 To UBound(arr4, 1) xb = Val(arr4(i, 1)) mmmm = arr4(i, 2) If SQL1 = "" Then SQL1 = "update clTemp2 set 错误题号=" & mmmm & " where ID=" & xb & "" Else SQL1 = SQL1 & ";" & "update clTemp2 set 错误题号=" & mmmm & " where ID=" & xb & "" End If Next sCnn.Execute (SQL) sCnn.Execute (SQL1) Set sCnn = Nothing End Sub
©️2020 CSDN 皮肤主题: 代码科技 设计师:Amelia_0503 返回首页