VB.NET,帶有MySQL的Winforms應用程序。在我的應用程序中,由於資金和連接可靠性的限制,我添加了通過使用郵件附件來更新它的功能。一切正常。那麼在應用程序表單加載,即使我有它檢查文件的存在。如果存在,則會對數據庫進行更改。所以下面的Sub被調用,並且該文件的內容被讀入到一個arrayList中...當應用程序從外部VS啓動時,我得到「CommandText屬性未正確初始化」錯誤。CommandText屬性尚未正確初始化
Private Sub sqlUpdate(ByVal sqlScriptName As String)
Dim D As Boolean = BackupDatabase("C:\xxxxxxxx\temp.sql")
Dim objReader As New StreamReader(sqlScriptName)
Dim sLine As String = ""
Dim arrText As New ArrayList()
Do
sLine = objReader.ReadLine()
If Not sLine Is Nothing Then
arrText.Add(sLine)
End If
Loop Until sLine Is Nothing
objReader.Close()
For Each sLine In arrText
Dim conn As New MySqlConnection
Dim myCommand As New MySqlCommand
Dim connString As String = My.Settings.storageConnectionString
conn.ConnectionString = connString
myCommand.Connection = conn
myCommand.CommandText = String.Empty
Try
myCommand.CommandText = sLine
conn.Open()
myCommand.ExecuteNonQuery()
Catch myerror As MySqlException
'MsgBox("There was an error updating the database: " & myerror.Message + vbNewLine + "PLEASE CONTACT THE DEVELOPER IMMEDIATELY")
End Try
Next
Return
End Sub
不知道是哪裏的問題正在添加從並遵循執行,一路下來...的SLIST包含像這樣有效的MySQL命令:
ALTER TABLE `storage`.`property_info` ADD COLUMN `pfam_pName` CHAR(200) NULL AFTER `pfam_Phone` ;
任何想法,可以發我在這個正確的方向?
快速評論別人提起這件事之前..我才意識到我不應該將其發送到一個ArrayList,我可以在每行上執行NonQuery而不是將其發送到ArrayList。 – Skindeep2366