wrong declaration? But I don't see what

G

Guest

Hi,

I just started my first .NET program

I keep it very simple at the moment but have problems declaring somthing:

I have two projects : a webservice and a consoleapp to test some functions
of the webservice

my code for the consoleapp
Module Module1
Sub Main()
Dim test2 As Dossier.RIPstraat = New Dossier.RIPstraat
test2.Splitadres("adres met straat kan eventueel lang zijn en nummer
45/B")
Console.WriteLine(test2.straat)
Console.WriteLine(test2.nummer)
Console.WriteLine(test2.bus)
'until here no problems
Dim test As Dossier.Zoekrecord = New Dossier.Zoekrecord
'the above statement creates an error, below nothing is executed anymore
Console.WriteLine("test")
test.Search("MNCLNT", "pkMNCLNTref", " = ", "3507")
Console.WriteLine("straat : " & test.PK)
Console.Read()
End Sub
End Module

I commented above when it goes wrong

part of my webservice :
this code "Public NepII As New OleDb.OleDbConnection" gives a warning
:"C:\inetpub\wwwroot\Dossier\Zoekrecord.vb(4): Policy Reminder: Project
'Dossier.vbproj' (Element projVBProject, projWebService) does not allow
Object 'NepII' (Element codeDataOLEDbConnection)
" so I guess there is somthing wrong here.

Public Class Zoekrecord
Private GevondenValue As Boolean
Private PKValue As String
Public NepII As New OleDb.OleDbConnection
Public Property Gevonden() As Boolean
Get
Return Gevonden
End Get
Set(ByVal Value As Boolean)
GevondenValue = Value
End Set
End Property
Public Property PK() As String
Get
Return PK
End Get
Set(ByVal Value As String)
PKValue = Value
End Set
End Property
Public Sub openconnection()
Try
NepII = New OleDb.OleDbConnection("FILE NAME=c:\hercules.udl")
'NepII.ConnectionString = "FILE NAME=c:\testDAT.udl"
NepII.Open()
Catch ex As OleDb.OleDbException
Dim i As Int16
For i = 0 To ex.Errors.Count - 1
MsgBox(ex.Errors(i).Message)
Next
End Try
End Sub
Public Sub closeconnection()
If (Not NepII Is Nothing) AndAlso (NepII.State =
ConnectionState.Open) Then NepII.Close()
End Sub

Public Sub Search(ByVal Tabel As String, ByVal veld As String, ByVal
operator As String, ByVal waarde As String)
Dim cmd As OleDb.OleDbCommand
Dim i As Int16
Dim sqlstring As String

If veld.Length = 0 Or Tabel Is Nothing Then
GevondenValue = -1
Else
openconnection()
sqlstring = "select * from " + Tabel
sqlstring = sqlstring + veld + operator + waarde
Try
cmd = New OleDb.OleDbCommand
cmd.CommandText = sqlstring
cmd.Connection = NepII
cmd.ExecuteReader()
' PKValue = cmd.Parameters.Item("pk" + Tabel + "ref").ToString
Catch ex As OleDb.OleDbException
For i = 0 To ex.Errors.Count - 1
MsgBox(ex.Errors(i).Message)
Next
End Try
'TODO verder nog opzoeken in DB en recordset vullen (als property)
closeconnection()
End If
End Sub
End Class


the error I get is
"An unhandled exception of type 'System.Security.SecurityException' occurred
in ConsoleApplication1.exe

Additional information: Request failed"

the break only gives me the "show disassembly" ...

if needed here is the code foor the function "RIPadres" this one does work
Public Class RIPstraat
Private straatValue As String
Private nummerValue As String
Private busValue As String

Public Property straat() As String
Get
Return straatValue
End Get
Set(ByVal Value As String)
straatValue = Value
End Set
End Property
Public Property nummer() As String
Get
Return nummerValue
End Get
Set(ByVal Value As String)
nummerValue = Value
End Set
End Property
Public Property bus() As String
Get
Return busValue
End Get
Set(ByVal Value As String)
busValue = Value
End Set
End Property

Public Sub Splitadres(ByVal adres As String)
Dim split As String() = Nothing
Dim s As String
Dim i As Int16 = 1

busValue = Nothing
split = adres.Split("/")
If split.Length() >= 2 Then
busValue = split(1) 'we nemen de eesrte na de slash
End If
i = 2
Do Until i > split.Length() - 1
busValue = busValue + "/" + split(i)
i = i + 1
Loop
split = split(0).Split(" ")
nummerValue = split(split.Length - 1)
straatValue = split(0)
i = 1
Do Until i >= split.Length - 1
straatValue = straatValue + " " + split(i)
i = i + 1
Loop

End Sub

End Class
 
G

Guest

Solution found!

reason was my code was on a network share and then you can expect 'strange
security problems'
Put it all on the C:-drive and it works
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top