0
我想讓我的程序導入在程序中輸入的數據,以更新MySQL中的表。我查看了代碼並做了一些研究,看起來應該可以工作,但數據沒有寫入MySQL服務器。任何幫助將不勝感激。以下是我的VB代碼和MySQL存儲過程。從VB程序中的數據沒有在MySQL中更新
Public Class OrePriceUpdate
Dim Mysqlconn As MySqlConnection
Dim cmd As MySqlCommand
Private Sub Update_Prices_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Update_Prices_Button.Click
Mysqlconn = New MySqlConnection()
Mysqlconn.ConnectionString = "server=xxxxxx;Uid=xxxx;Pwd=xxxxxx;database=xxxx"
Try
Mysqlconn.Open()
cmd = New MySqlCommand()
cmd.Connection = Mysqlconn
cmd.CommandText = "update_ore_prices"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@veldspar", Veldspar_Isk.Text)
Catch myerror As MySqlException
MessageBox.Show(myerror.Message)
Finally
Mysqlconn.Dispose()
End Try
End Sub
SQL查詢
DELIMITER $$
USE `YHI`$$
DROP PROCEDURE IF EXISTS `update_ore_prices`$$
CREATE DEFINER=`YHI`@`%` PROCEDURE `update_ore_prices`(
IN veldspar DECIMAL(10,2)
BEGIN
INSERT INTO Ore_Ice_Prices(
Veldspar
VALUES(
veldspar);
END$$
DELIMITER ;