I use codes below to inserts values to database by executing stored procedure.
Dim connstring As String = "dsn=test"
Dim oConn As Odbc.OdbcConnection = New Odbc.OdbcConnection(connstring)
Dim com As New Odbc.OdbcCommand("{? = call sp_test1(?,?,?,?)}", oConn)
com.CommandType = CommandType.StoredProcedure
com.Parameters.AddWithValue("@Code", 2)
com.Parameters.AddWithValue("@Name", "2")
com.Parameters.AddWithValue("@Familly", "2")
com.Parameters.AddWithValue("@Pname", "2")
oConn.Open()
com.ExecuteNonQuery()
oConn.Close()
but I got this error
ERROR [HY105] [Microsoft][ODBC SQL Server Driver]Invalid parameter type
and here is my stored procedure
USE [test]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create Procedure [dbo].[sp_test1]
@Code bigint,
@Name nvarchar(50),
@Familly nvarchar(50),
@Pname nvarchar(50),
As
Begin
Insert Into test1
([Code],[Name],[Familly],[Pname])
Values
(@Code,@Name,@Familly,@Pname)
Declare @ReferenceID int
Select @ReferenceID = @@IDENTITY
Return @ReferenceID
End
is there a solution ?