Guest_imported
New member
- Jan 1, 1970
- 0
Hi all,
I have a really long field called "Message" in my database. Below is the sample out put of it:
"id=firewall sn=00401012401B time=""2002-04-02 17:17:50"" fw=216.191.177.98 pri=6 c=1024 m=98 n=139575 src=10.0.1.1:53:LAN dst=206.191.82.255:53:WAN proto=udp/dns sent=54 37:WANult=304 dstname=adiscon.orgarg=/Seminars/RuleEngine_files/audio%20slides%20html%20toc%20resiz...
"
As you can see that its a big field. Out of this field I am extracting the src IP address. In the above case it would be src=10.0.1.1
I want to extract this IP address, in other words thats the only data I am concerned with. I have tried the split function and below is my code.
_________________________________________________________
Option Compare Database
Option Explicit
Sub EventsMessage()
Dim cnnlocal As ADODB.Connection
Dim cmdlocal As ADODB.Command
Dim Events As ADODB.Recordset
Dim intUpdate As Integer
Dim str As Integer
Dim i As Integer
Set cnnlocal = New ADODB.Connection
cnnlocal.ConnectionString = "DSN=Wsyslog"
cnnlocal.Open
Set cmdlocal = New ADODB.Command
Set cmdlocal.ActiveConnection = cnnlocal
cmdlocal.CommandText = "Select * from Info"
Events.CursorType = adOpenForwardOnly
Set Events = cmdlocal.Execute
intUpdate = 0
Do While Not Events.EOF
intUpdate = intUpdate + 1
str = Events.Fields("Message"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
str = Split(Trim(str), " "![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Events.Fields("Message"
= Split(Trim(str), " "![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
If Left(str(i), 4) = "src=" Then
str = Left(str(i), InStr(1, str(i), ":"
- 1)
End If
Events.Fields("Message"
= str
Events.Update
Events.MoveNext
Loop
Debug.Print intUpdated & " Records Updated"
Events.Close
End Sub
_________________________________________________________
I get the error saying "Compile Error; Expected Variable or Procudure Not Module." It then highlights the Split in str = Split(Trim(str), " "
. I am using Access 97 with VBA. My guess is that Split is not a recognized command. Can any one help me with this code or suggest a better one???
I have a really long field called "Message" in my database. Below is the sample out put of it:
"id=firewall sn=00401012401B time=""2002-04-02 17:17:50"" fw=216.191.177.98 pri=6 c=1024 m=98 n=139575 src=10.0.1.1:53:LAN dst=206.191.82.255:53:WAN proto=udp/dns sent=54 37:WANult=304 dstname=adiscon.orgarg=/Seminars/RuleEngine_files/audio%20slides%20html%20toc%20resiz...
"
As you can see that its a big field. Out of this field I am extracting the src IP address. In the above case it would be src=10.0.1.1
I want to extract this IP address, in other words thats the only data I am concerned with. I have tried the split function and below is my code.
_________________________________________________________
Option Compare Database
Option Explicit
Sub EventsMessage()
Dim cnnlocal As ADODB.Connection
Dim cmdlocal As ADODB.Command
Dim Events As ADODB.Recordset
Dim intUpdate As Integer
Dim str As Integer
Dim i As Integer
Set cnnlocal = New ADODB.Connection
cnnlocal.ConnectionString = "DSN=Wsyslog"
cnnlocal.Open
Set cmdlocal = New ADODB.Command
Set cmdlocal.ActiveConnection = cnnlocal
cmdlocal.CommandText = "Select * from Info"
Events.CursorType = adOpenForwardOnly
Set Events = cmdlocal.Execute
intUpdate = 0
Do While Not Events.EOF
intUpdate = intUpdate + 1
str = Events.Fields("Message"
str = Split(Trim(str), " "
Events.Fields("Message"
If Left(str(i), 4) = "src=" Then
str = Left(str(i), InStr(1, str(i), ":"
End If
Events.Fields("Message"
Events.Update
Events.MoveNext
Loop
Debug.Print intUpdated & " Records Updated"
Events.Close
End Sub
_________________________________________________________
I get the error saying "Compile Error; Expected Variable or Procudure Not Module." It then highlights the Split in str = Split(Trim(str), " "