Hi all,
I am using VB 5.0 and msaccess as a database, I am reading the data from logfiles and inserting it in db, its not throwing any error, but after excecution I not find any records in table Below is my code:
Public strfile As String
Dim newdate, predate, olddate As Date
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim rs1 As New ADODB.Recordset
Public Sub Form_Load()
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set rs1 = New ADODB.Recordset
cn.Open "DSN=MS Access Database12"
cn.Execute "delete from hitfile"
cn.Execute "delete from hitresult"
cn.Execute "delete from logfile"
cn.Execute "delete from result"
'checking date for validity
newdate = Date - 1
predate = DateAdd("m", -4, newdate)
olddate = predate
'generating the log file name
'------------------------------------------------------------
'when the from & to date of the period is entered by the user
While olddate <= newdate + 1
If olddate > newdate Then
Call resultfun
Else
strfile = "ex" & Format(olddate, "yy") & Format(olddate, "mm") & Format(olddate, "dd")
Call readfile
End If
olddate = olddate + 1
Wend
Unload Me
End Sub
Function resultfun()
qry = "select username,date1,count(username) from logfile group by username,date1"
rs.Open qry, cn
While Not rs.EOF
If rs.Fields(0).Value = "-" Then
rs.MoveNext
Else
If rs.Fields(0).Value <> "administrator" And rs.Fields(0).Value <> "narendra" Then
cn.Execute "insert into result values('" & rs.Fields(1) & "','" & rs.Fields(0) & "','" & rs.Fields(0).Value & "@cisco.com'," & rs.Fields(2).Value & ")"
End If
rs.MoveNext
End If
Wend
Unload Me
End
End Function
Function readfile()
Dim obj As New Scripting.FileSystemObject
Dim arr(11)
c = 0
strfilename = "c:\winnt\system32\logfiles\w3svc1\" & strfile & ".log"
obj.GetFile strfilename
Set objtextstream = obj.OpenTextFile(strfilename, ForReading)
Do While Not objtextstream.AtEndOfStream
strreadingline = objtextstream.ReadLine
'Excluding all the headings and field names from the log file
If strreadingline <> "" And InStr(1, strreadingline, "#") = 0 Then
'The login entry starts from line no 4
If (c > 3) Then
i = 1
From = 1
cnt = 0
temp1 = 1
posn = 0
'Each entry has got 11 fields
While (cnt < 11)
'Splitting each line of text into several fields based on the blank space
From = posn + 1
posn = InStr(From, strreadingline, " ")
If posn = 0 Then
posn = Len(strreadingline) - From + 1
arr(cnt) = Mid(strreadingline, From, posn)
Else
arr(cnt) = Mid(strreadingline, From, posn - From)
End If
cnt = cnt + 1
temp1 = From + 1
Wend
'Discard all the administrator entries
If IsDate(arr(0)) Then
On Error Resume Next
If arr(9) = 302 Then
'MsgBox arr(7)
On Error Resume Next
cn.Execute "insert into logfile values('" & arr(0) & "','" & arr(1) & "','" & arr(2) & "','" & arr(3) & "','" & arr(4) & "'," & arr(5) & ",'" & arr(6) & "','" & arr(7) & "'," & arr(9) & ",'" & arr(10) & "')"
End If
End If
If IsDate(arr(0)) And arr(3) <> "-" And arr(3) <> "administrator" And arr(3) <> "narendra" And arr(3) <> "narenda" Then
a = arr(1)
'Extract the log entry for accessing some document
If (InStr(1, arr(7), ".") <> 0) And InStr(1, arr(7), "resources") = 0 And (InStr(1, arr(7), "Documents") <> 0 Or InStr(1, arr(7), "documents") <> 0) And InStr(1, arr(7), "gif") = 0 Then
On Error Resume Next cn.Execute "insert into hitfile values('" & arr(0) & "','" & arr(2) & "','" & arr(3) & "','" & arr(4) & "','" & arr(6) & "','" & arr(7) & "'," & arr(9) & ",'" & arr(10) & "')" slash = InStr(26, arr(7), "/")
Docname = Mid(arr(7), slash + 1)
On Error Resume Next
cn.Execute "insert into hitresult values('" & arr(0) & "','" & arr(3) & "','" & Docname & "')"
End If
End If
End If
End If
c = c + 1
Loop
End Function
7 1752
juat a reminder for my previous query
juat a reminder for my previous query
What type of connection you are using
1. jet 4.0
2. DSN
chect the database file path in the connection.
What type of connection you are using
1. jet 4.0
2. DSN
chect the database file path in the connection.
Its DSN path is correct if I give some othere table name its updating that.. only the tables which I am updating from log files are not getting updated
Its DSN path is correct if I give some othere table name its updating that.. only the tables which I am updating from log files are not getting updated
On Error Resume Next
cn.Execute "insert into hitfile values('" & arr(0) & "','" & arr(2) & "','" & arr(3) & "','" & arr(4) & "','" & arr(6) & "','" & arr(7) & "'," & arr(9) & ",'" & arr(10) & "')"
Remove that On Error Resume Next then it'll throw error.
then you'll be clear.
On Error Resume Next
cn.Execute "insert into hitfile values('" & arr(0) & "','" & arr(2) & "','" & arr(3) & "','" & arr(4) & "','" & arr(6) & "','" & arr(7) & "'," & arr(9) & ",'" & arr(10) & "')"
Remove that On Error Resume Next then it'll throw error.
then you'll be clear.
ok let me try that.. thank you
ok let me try that.. thank you
Hey I recreated the table.. now its working fine..
Hey I recreated the table.. now its working fine..
Can you give, what is the error you got? so that'll help others to avoid posting new query.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: tperovic |
last post by:
Using SS2K, I'm getting the following error while bulk inserting:
Column 'warranty_expiration_date' cannot be modified because it is a
computed column.
Here is my bulk insert statement:
...
|
by: shottarum |
last post by:
I currently have 2 tables as follows:
CREATE TABLE .
(
mhan8 int,
mhac02 varchar(5),
mhmot varchar(5),
mhupmj int
)
|
by: serge |
last post by:
I have a scenario where two tables are in a One-to-Many relationship
and I need to move the data from the Many table to the One table so
that it becomes a One-to-One relationship.
I need to...
|
by: Guru |
last post by:
Hi
I have a table which contains number of rows. I want to fetch the
last 5 records from the table. I know for the first 'n' records we can
use FETCH FIRST n ROWS ONLY command. But i want to...
|
by: Trevor |
last post by:
Hey,
I am trying to do this tutorial on the microsoft site :
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dndotnet/html/usingadonet.asp
I can get everything to work up to...
|
by: keith.culpepper |
last post by:
Can anyone please provide some assistance with a trigger that I need to
develop. Here is the situation:
Our program updates depend on database updates. If a client receives
the program update...
|
by: sql_server_user |
last post by:
I'm trying to copy all 440 million rows from one table in my SQL Server
2005 db to another table with a different clustering scheme. After a
few test inserts that were successful (up to a million...
|
by: polocar |
last post by:
Hi,
I'm writing a program in Visual C# 2005 Professional Edition.
This program connects to a SQL Server 2005 database called
"Generations" (in which there is only one table, called...
|
by: pinko1204 |
last post by:
My Update function cannot successful update to sql table even don't have any error. Please help to check .....thx
PHP1
<?php
require_once 'header.php';
?>
<style type="text/css">
<!--
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |