为什么某些表单突然失去功能?

时间:2014-12-08 23:17:56

标签: mysql database vb.net

偶尔在这个应用程序中,我一直在处理一个表单会突然失去它在数据库中的所有功能,我被迫删除我在其上完成的所有工作并完全重新建立它。

例如,向数据库添加新条目;我可以点击Add New调用bindingsource.addnew()将所有需要的信息输入到文本框中,点击保存然后当我关闭并重新打开表格时,数据网格中没有显示任何内容。如果我直接进入SQL数据库中的表,这里也没有添加任何内容吗?

它似乎突然升级,当我编辑表中的条目然后保存它不更新。之后,我无法添加行,但它会让我删除行并保存?

Tablename.bindingsource.addnew()

Tablename.bindingsource.endedit()
Tablename.tableadapter.update(datasetname.tablename)

这是我用于添加行并保存新条目以及编辑数据源一段时间的内容。有什么我需要注意的吗?

Private Sub createnew()
    '' CREATE AND SAVE NEW ENTRY
    CalibratedEquipmentBindingSource.AddNew()
    dateaddedlbl.Text = datelbl.Text
    CalibratedEquipmentBindingSource.EndEdit()
    Calibrated_EquipmentTableAdapter.Update(MacroQualityDataSet.Calibrated_Equipment)
End Sub

Private Sub savebtn_Click(sender As Object, e As EventArgs) Handles savebtn.Click

    Try
        Dim accountname As String = "macroqc"
        Dim acocuntkey As String = My.Settings.Storagekey1

        Dim creds As StorageCredentials = New StorageCredentials(accountname, acocuntkey)
        Dim account As CloudStorageAccount = New CloudStorageAccount(creds, useHttps:=True)

        Dim client = account.CreateCloudBlobClient()

        Dim container As CloudBlobContainer = client.GetContainerReference(My.Settings.smallequipmentcertscontainername)
        container.CreateIfNotExists()

        Dim blob As CloudBlockBlob = container.GetBlockBlobReference(My.Settings.ticketsource)
        Using FileStream = System.IO.File.OpenRead(My.Settings.ticketsource)
            blob.UploadFromStream(FileStream)
            filenamelbl.Text = My.Settings.ticketsource

            '' GET HTTPS: PATH OF BLOB
            ''blob.Uri.AbsoluteUri & blob.Uri.AbsolutePath

        End Using

    Catch ex As Exception
        MessageBox.Show("Sorry an error has occured while uploading your file: " & Environment.NewLine & ex.ToString, "Upload Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try

    If datelbl.Text.Length > 3 Then
        dateeditedlbl.Text = datelbl.Text
    End If

    CalibratedEquipmentBindingSource.EndEdit()
    Calibrated_EquipmentTableAdapter.Update(MacroQualityDataSet.Calibrated_Equipment)
    gridcolors()
    MsgBox("Save Complete!")
End Sub

End Class

0 个答案:

没有答案