更改代码以在VS2017中使用sqlite db而不是现有的.mdb [英] Change code to use sqlite db instead of existing .mdb in VS2017
问题描述
我一直在使用Visual Studio 2010在一个使用sqlite .db数据库的字母编写程序上进行显示调整。在使用Visual Studio 2010的XP机器上使用它时,它完美地工作,并且生成的程序在XP,Win 7和win10机器上正确安装和运行。
我的问题是我现在已经改为使用VS 2017的win 10机器,当转换后加载项目时,它似乎已经从sqlite改变了。
我在win 10机器上安装并使用了sqlite,并且能够附加正确的数据库。
有关如何使用的任何建议解开这个烂摊子?我正在寻找如何继续学习相当陡峭的学习曲线的指导。
我复制了以下主要表格的VB代码的开头:
我的尝试:
Imports 系统
Imports System.IO
Imports System.Collections
Imports System.Data.SQLite
Imports Word = Microsoft.Office.Interop.Word
Imports System.Threading
Imports System.Runtime.InteropServices
公共 类字母
< span class =code-keyword> Dim m_SqlCommand As SqlClient.SqlCommand
Dim m_tempCommand 作为 SqlClient.SqlCommand
Dim m_tempReader As SqlClient.SqlDataReader
Dim m_SqlCommand1 As SqlCommand
Dim m_SqlReader As SqlDataReader
Dim m_SqlReader1 As SqlDataReader
Dim mLetterIndex As 字符串
Dim mSingleSenderTemplate 作为 字符串
Dim mDoubleSenderTemplate 作为 字符串
Dim mPDFTemplate 作为 字符串
私有 Sub frmMain_Load( ByVal sender As < span class =code-keyword> Object , ByVal e As System.EventArgs) 句柄 我 .Load
cboSenderOneTitle.Focus()
调用 SetControlValues()
gbSubHeadingText.Visible = 错误
结束 Sub
私有 Sub btnSelectLetter_Click( ByVal sender As System。 Objec t , ByVal e As System.EventArgs)句柄 btnSelectLetter.Click
调用 GetControlValues()
如果 gSenderOneLastName = gSenderTwoLastName 然后
CombinedSendFrench.Text =(gFR1Title)& et& gTitle2FR& & gSenderOneForenames& & gSenderOneLastName
ElseIf gSenderOneLastName<> gSenderTwoLastName 然后
CombinedSendFrench.Text =(gFR1Title)& & gSenderOneForenames& & gSenderOneLastName& et& gTitle2FR& & gSenderTwoForenames& & gSenderTwoLastName
结束 如果
Dim mstrSQL As String
Dim conn As 新 SqlConnection()
conn.ConnectionString = DataSource = .\SQLlite; AttachDbFilename = LetterSelectorDB.db & Application.StartupPath & \ & LetterSelectorDB.db &; Integrated Security = True; User Instance = True
conn.Open()
开始于添加一个双引号在这里:conn.ConnectionString = DataSource所以它看起来像这样:
conn.ConnectionString =DataSource
I have been Visual Studio 2010 to make display tweeks on a letter writing program which uses a sqlite .db database. whilst using it on an XP machine with Visual Studio 2010 it worked perfectly and the resulting program installs and runs correctly on XP, Win 7 and win10 machines.
My problem is that I have now changed to a win 10 machine with VS 2017 and when the project loaded after conversion it seems to have been changed away from sqlite.
I have sqlite installed and usable on the win 10 machine and have been able to attach the correct database.
Any suggestions as to how to untangle this mess? I am looking for guidance on how to proceed on my rather steep learning curve.
I have copied the start of VB code of the main form below:
What I have tried:
Imports System
Imports System.IO
Imports System.Collections
Imports System.Data.SQLite
Imports Word = Microsoft.Office.Interop.Word
Imports System.Threading
Imports System.Runtime.InteropServices
Public Class Letters
Dim m_SqlCommand As SqlClient.SqlCommand
Dim m_tempCommand As SqlClient.SqlCommand
Dim m_tempReader As SqlClient.SqlDataReader
Dim m_SqlCommand1 As SqlCommand
Dim m_SqlReader As SqlDataReader
Dim m_SqlReader1 As SqlDataReader
Dim mLetterIndex As String
Dim mSingleSenderTemplate As String
Dim mDoubleSenderTemplate As String
Dim mPDFTemplate As String
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
cboSenderOneTitle.Focus()
Call SetControlValues()
gbSubHeadingText.Visible = False
End Sub
Private Sub btnSelectLetter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectLetter.Click
Call GetControlValues()
If gSenderOneLastName = gSenderTwoLastName Then
CombinedSendFrench.Text = (gFR1Title) & " et " & gTitle2FR & " " & gSenderOneForenames & " " & gSenderOneLastName
ElseIf gSenderOneLastName <> gSenderTwoLastName Then
CombinedSendFrench.Text = (gFR1Title) & " " & gSenderOneForenames & " " & gSenderOneLastName & " et " & gTitle2FR & " " & gSenderTwoForenames & " " & gSenderTwoLastName
End If
Dim mstrSQL As String
Dim conn As New SqlConnection()
conn.ConnectionString =DataSource=.\SQLlite;AttachDbFilename=LetterSelectorDB.db" & Application.StartupPath & "\" & "LetterSelectorDB.db" & ";Integrated Security=True;User Instance=True"
conn.Open()
Start by adding a double quote in here:conn.ConnectionString =DataSourceso it looks like this:
conn.ConnectionString ="DataSource
这篇关于更改代码以在VS2017中使用sqlite db而不是现有的.mdb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!