ADO.NET param error in XML W/s for Distributed App -
06-23-2006
, 04:03 PM
Hi Folks
I am getting an error associated with a parameter for a cmd which runs a SP.
The error occurs when the prm.direction property is set.
This is part of the overall code from the top down to where the exception
occurs:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
<WebMethod(Description:="Adds a Client to the Clients Table.")> _
Public Sub ClientInsert(ByVal strClientType As String, _
ByVal strClientLastName As String, _
ByVal strClientFirstName As String, _
ByVal strClientOtherNames As String, _
ByVal strClientOrgName As String, _
ByVal strClientAddress1 As String, _
ByVal strClientAddress2 As String, _
ByVal strClientSuburbTown As String, _
ByVal strClientState As String, _
ByVal strClientPostCode As String, _
ByVal strNote As String, _
ByVal strEmpCreated As String, _
ByVal strEmpUpdated As String)
Dim cn As SqlConnection
Dim cmd As SqlCommand
Dim prm As SqlParameter
Dim strConnInfo As String
Dim intClientID As Integer
'this is the conection string to connect to the DB
strConnInfo = "server=(local);uid=sa;pwd=;integrated
security=SSPI;persist security info=False;initial catalog=Clients"
Try
'connect to the DB
cn = New SqlConnection
cn.ConnectionString = strConnInfo
cn.Open()
'having successfully connected to the DB, now we can set up the
command and run it to add the new record
Try
cmd = New SqlCommand
cmd.Connection = cn
cmd.CommandText = "proc_ClientsInsert"
cmd.CommandType = CommandType.StoredProcedure
With prm
prm = cmd.Parameters.Add(New SqlParameter("@clienttype",
SqlDbType.VarChar, 12))
.Direction = ParameterDirection.Input
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
This is what is showing up in the locals window for the exception:
@@@@@@@@@@@@@@
- ex {System.NullReferenceException} System.Exception
Message "Object reference not set to an instance of an object." String
@@@@@@@@@@@@@@
in the web.config file I have an additional line in there as follows:
<identity impersonate="true"/>
I doubt if that is the reason anyway.
It is probably the case that I am missing something obvious, but I cannot
see it, so if somebody could help, I would muchly appreciate it.
Thanks in advance
Kind regards
Ross Petersen |