Click here to Skip to main content
15,899,126 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Public Function insert(ByVal SP_Name As String) As Integer
    Dim c As DBaccess = New DBaccess
    Dim a As Integer
    c.connect()
    c.cmd = New OdbcCommand(SP_Name, c.con)
    c.cmd.CommandType = CommandType.StoredProcedure
    c.cmd.Parameters.AddWithValue("_ID", _ID)
    c.cmd.Parameters.AddWithValue("_NAME", _NAME)
    a = c.cmd.ExecuteNonQuery()
    c.disconnect()
    If a > 0 Then
        Return 1
    Else
        Return -1
    End If
End Function
Posted
Updated 18-Mar-16 9:24am
v2
Comments
Abhipal Singh 19-Mar-16 2:59am    
Can you add the entire exception message and stack trace along with your question? without that, there is no way to fix the problem. I don't believe in guessing the issues and providing solutions.

The first thing to do is put a breakpoint on the first line of that code and see what value is being passed in as the SP_Name. Does the actual SP exist? Then check the values in the parameters, and ensure they have "sensible" values - the name isn't over long, and neither of them are null for example.

We can't solve this for you - it depends too much on the rest of your system, and we can't run against that because we have no idea what is happening other than the small code fragment your have supplied. Time for you get learn some debug-fu! :laugh:
 
Share this answer
 
OdbcException[^] is generated when a warning or error is returned by an ODBC data source.

You can try:
Troubleshooting Exceptions: System.Data.Odbc.OdbcException[^]

--Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900