mysql - 存储过程 VB.NET MYSQL

标签 mysql sql vb.net stored-procedures dbnull

你好,我仍然有问题,它给我带来了 DBnull,我尝试了 Store 过程并且工作正常。这是我的代码。如果有人可以帮助我,我将不胜感激。

        conexion.Open()
        command.Connection = conexion
        command.CommandText = "TraerPaisOrigen"
        command.CommandType = CommandType.StoredProcedure

        command.Parameters.AddWithValue("@Cod_Dua", TxtCodDUA.Text)
        command.Parameters("@Cod_Dua").Direction = ParameterDirection.Input



        command.Parameters.AddWithValue("@_PaisOrigen", MySqlDbType.VarChar)
        command.Parameters("@_PaisOrigen").Direction = ParameterDirection.Output
        command.ExecuteNonQuery()

        'XML_PaisOrigen is a String

        XML_PaisOrigen = command.Parameters(0).Value.ToString




        conexion.Close()

我的存储过程

CREATE PROCEDURE TraerPaisOrigen( IN Cod_Dua INT, OUT _PaisOrigen VARCHAR(2))

最佳答案

这个:

command.Parameters.AddWithValue("@Cod_Dua", TxtCodDUA.Text)
command.Parameters("@Cod_Dua").Direction = ParameterDirection.Input

应该是这样的:

command.Parameters.AddWithValue("@Cod_Dua", CInt(TxtCodDUA.Text))

这个:

command.Parameters.AddWithValue("@_PaisOrigen", MySqlDbType.VarChar)
command.Parameters("@_PaisOrigen").Direction = ParameterDirection.Output

应该是这样的:

command.Parameters.Add("@_PaisOrigen", MySqlDbType.VarChar, 2).Direction = ParameterDirection.Output

这个:

XML_PaisOrigen = command.Parameters(0).Value.ToString

应该是这样的:

XML_PaisOrigen = command.Parameters(1).Value.ToString()

关于mysql - 存储过程 VB.NET MYSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25375919/

相关文章:

mysql - Yii2 将数据库表镜像到 redis 以实现高速事件记录查询

MySQL : Does a query searches inside the whole table?

c# - 选择 Cast (Scope_identity) 并执行标量

vb.net - 无法设置 Outlook.TaskItem 的 RTFBody 属性

MySQL 向变量中插入一列

c# - Visual Studio 2010 中的重构选项在 C# 和 VB 之间有所不同

php - 使用 php 将 JSON 数据插入 mysql

php - 缓慢的PHP进程

PHP/MySQL : SQL Statement from different columns

sql - Oracle 查询中避免更新字段的最佳方法是什么(如果未更改)?