473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

table is not getting updated, even though insert statement is successful

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
Aug 13 '07 #1
7 1752
juat a reminder for my previous query
Aug 27 '07 #2
hariharanmca
1,977 1GB
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.
Aug 27 '07 #3
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
Aug 27 '07 #4
hariharanmca
1,977 1GB
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.
Aug 27 '07 #5
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
Aug 27 '07 #6
ok let me try that.. thank you
Hey I recreated the table.. now its working fine..
Aug 27 '07 #7
hariharanmca
1,977 1GB
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.
Aug 27 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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: ...
1
by: shottarum | last post by:
I currently have 2 tables as follows: CREATE TABLE . ( mhan8 int, mhac02 varchar(5), mhmot varchar(5), mhupmj int )
14
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...
20
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...
10
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...
5
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...
6
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...
6
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...
3
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"> <!--
0
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,...
0
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$) { } ...
0
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...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.