Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Calling a function gives me very unhelpful error message

Calling a function gives me very unhelpful error message

Scheduled Pinned Locked Moved Visual Basic
pythonsharepointdebugginghelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DerekFL
    wrote on last edited by
    #1

    Im trying to debug a function in VB My code looks like this. When I call Dim Ip as Int64 = GetLocId("192.168.1.1, cn) I get error "Syntax error or access violation" Its got to be something stupid I am doing. Namespace Ip Public Class Class1 Public Function GetLocId(ByVal Ip As String, ByVal connection As String) As Int64 Dim cn As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(connection) Dim command As String = "EXEC [dbo].[sp_location_i]" 'Dim IpId As Int64 Dim IpLocId As Int64 cn.Open() Dim cmd As System.Data.OleDb.OleDbCommand = cn.CreateCommand() cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = command Dim pIp As OleDbParameter = cmd.Parameters.Add("@Ip", OleDb.OleDbType.VarChar, 15) pIp.Value = Ip Dim pIpLocId As OleDbParameter = cmd.Parameters.Add("@IpLocId", OleDbType.BigInt) pIpLocId.Direction = ParameterDirection.Output 'Try cmd.ExecuteNonQuery() 'Catch exc As OleDbException ' Console.WriteLine(exc.Message) ' IpLocId = 0 --Unknow location 'Finally cn.Close() 'End Try IpLocId = Convert.ToInt64(pIpLocId.Value) Return IpLocId End Function End Class End Namespace

    S 1 Reply Last reply
    0
    • D DerekFL

      Im trying to debug a function in VB My code looks like this. When I call Dim Ip as Int64 = GetLocId("192.168.1.1, cn) I get error "Syntax error or access violation" Its got to be something stupid I am doing. Namespace Ip Public Class Class1 Public Function GetLocId(ByVal Ip As String, ByVal connection As String) As Int64 Dim cn As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(connection) Dim command As String = "EXEC [dbo].[sp_location_i]" 'Dim IpId As Int64 Dim IpLocId As Int64 cn.Open() Dim cmd As System.Data.OleDb.OleDbCommand = cn.CreateCommand() cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = command Dim pIp As OleDbParameter = cmd.Parameters.Add("@Ip", OleDb.OleDbType.VarChar, 15) pIp.Value = Ip Dim pIpLocId As OleDbParameter = cmd.Parameters.Add("@IpLocId", OleDbType.BigInt) pIpLocId.Direction = ParameterDirection.Output 'Try cmd.ExecuteNonQuery() 'Catch exc As OleDbException ' Console.WriteLine(exc.Message) ' IpLocId = 0 --Unknow location 'Finally cn.Close() 'End Try IpLocId = Convert.ToInt64(pIpLocId.Value) Return IpLocId End Function End Class End Namespace

      S Offline
      S Offline
      Steven J Jowett
      wrote on last edited by
      #2

      I think problem is with this :-

      DerekFL wrote:

      Dim command As String = "EXEC [dbo].[sp_location_i]"

      Change the Dim command line to Dim command as String = "dbo.sp_location_i". leave out the EXEC.

      Steve Jowett ------------------------- It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)

      D 1 Reply Last reply
      0
      • S Steven J Jowett

        I think problem is with this :-

        DerekFL wrote:

        Dim command As String = "EXEC [dbo].[sp_location_i]"

        Change the Dim command line to Dim command as String = "dbo.sp_location_i". leave out the EXEC.

        Steve Jowett ------------------------- It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)

        D Offline
        D Offline
        DerekFL
        wrote on last edited by
        #3

        Thanks Steve. I knew it was something stupid.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups