我有一個在Visual Studio和SQL Server Compact Edition 3.5中創建的桌面應用程序。我可以插入一條沒有錯誤的記錄。我的問題是運行更新後沒有錯誤,之後數據庫沒有任何更改。更新*。使用VB.NET的SDF數據庫文件
這裏是我的更新代碼:
Dim Cmd As SqlCeCommand
Try
If Con.State = ConnectionState.Closed Then Con.Open()
Cmd = New SqlCeCommand("Update [Meds] SET [Brand] [email protected],[GenericName][email protected],[Dosage][email protected],[Form][email protected],[StockDose][email protected],[Supplier][email protected],[Manufacturer][email protected],[Quantity][email protected],[PerUnit1][email protected],[ExpiryDate][email protected],[SellingPrice][email protected] WHERE [PerUnit2] [email protected]", Con)
Cmd.Parameters.Add(New SqlCeParameter("@Brand", SqlDbType.NVarChar)).Value = txtBrand.Text
Cmd.Parameters.Add(New SqlCeParameter("@GenericName", SqlDbType.NVarChar)).Value = txtGenericName.Text
Cmd.Parameters.Add(New SqlCeParameter("@Dosage", SqlDbType.NVarChar)).Value = txtDosage.Text
Cmd.Parameters.Add(New SqlCeParameter("@Form", SqlDbType.NVarChar)).Value = cbForm.SelectedText
Cmd.Parameters.Add(New SqlCeParameter("@StockDose", SqlDbType.NVarChar)).Value = txtStockDose.Text
Cmd.Parameters.Add(New SqlCeParameter("@Supplier", SqlDbType.NVarChar)).Value = txtSupplier.Text
Cmd.Parameters.Add(New SqlCeParameter("@Manufacturer", SqlDbType.NVarChar)).Value = txtManufacturer.Text
Cmd.Parameters.Add(New SqlCeParameter("@Quantity", SqlDbType.NVarChar)).Value = txtQty.Text
Cmd.Parameters.Add(New SqlCeParameter("@PerUnit1", SqlDbType.NVarChar)).Value = cbPerUnit1M.SelectedText
Cmd.Parameters.Add(New SqlCeParameter("@ExpiryDate", SqlDbType.DateTime)).Value = dtpExpiry.Value
Cmd.Parameters.Add(New SqlCeParameter("@SellingPrice", SqlDbType.NVarChar)).Value = txtPrice.Text
Cmd.Parameters.Add(New SqlCeParameter("@PerUnit2", SqlDbType.NVarChar)).Value = cbPerUnit2M.SelectedText
Cmd.ExecuteNonQuery()
MsgBox("Items already UPDATED!")
List.Show()
Me.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Con.Close()
請分享您的連接字符串 – ErikEJ
Dim Con As OleDbConnection = New OleDbConnection(「Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\ Users \ Adrian \ Documents \ Pharmacy.accdb;」) – dran1979
這不是SQL Server精簡版,即Microsoft Access? ! – ErikEJ