Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WHAT IS THE PROBLEM WITH THIS CODE!!!!!!!!

Status
Not open for further replies.

pamo

Technical User
Oct 28, 2002
17
0
0
GB
HI BELOW IS A CODE I HAVE WRITTEN WHICH DOES NOT SEEM TO BE WORKING. I CANNOT IDENTIFY ANY PROBLEMS WITH IT, CAN U !!!! CHEERS FOR ANY 1 WHO CAN

PAMO

HERE IS THE CODE COPY AND PASTE IT INTO NOTEPAD OR SOMETHING:

dim varLOOP
dim Sqlstring
dim SqlInsert
dim Conn
dim Rs
dim ConnWrite
dim objcmd
dim strconn
dim LpCount
dim var_day
dim var_month
dim var_year
dim var_logon_date
dim var_logoff_date

on error resume next

'**********************************************************************************************************************
'set variable
varLOOP = 1

'start loop for month value
Do until varLOOP =13
'**********************************************************************************************************************
'msgbox varLOOP

'build connection string to required DB
'work out month from loop counter
DBMonth = varLOOP

'if month is less than 10 then add a zero
if DBMonth < 10 then
DBMonth = &quot;0&quot; & DBMonth
end if

DBYear = &quot;2002&quot;

'create ms access db filename
accessDB = &quot;histcrec&quot; & DBMonth & DBYear & &quot;.mdb&quot;

strconn=&quot;PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=&quot;
strconn=strconn & &quot;Q:\rtarchdata\&quot; & accessDB & &quot;;&quot;

'msgbox accessDB

'Build SQLstring

sqlstring = &quot;select * from callrecorddata&quot;




set Conn = createobject(&quot;adodb.connection&quot;)
set Rs = createobject(&quot;adodb.recordset&quot;)
Conn.open = strconn
Rs.open SqlString, Conn
LpCount = 0

err.clear

if Rs.eof then

set ConnWrite = createobject(&quot;adodb.connection&quot;)

ConnWrite.open = &quot;DSN=CallScan&quot;

Sqlinsert = SqlInsert & &quot;insert into callrecorddataerr (agent_id)&quot;
Sqlinsert = SqlInsert & &quot;values ('0')&quot;

ConnWrite.Execute(SQLinsert)

else:

set ConnWrite = createobject(&quot;adodb.connection&quot;)
ConnWrite.open = &quot;DSN=CallScan&quot;


do until Rs.eof

'Build a SQL insert string
SqlInsert = &quot;&quot;
Sqlinsert = SqlInsert & &quot;(call_id, start_date, end_date, call_source, call_destination, queue_duration, ring_duration, call_duration, clerical_duration, enquiry_duration, source_hold_duration, dest_hold_duration, park_duration, call_type, call_origin_type, call_termination_type, agent_id, agent_group, src_agent_id, queue_id, call_info, tli_oli_digits, &quot;

Sqlinsert = SqlInsert & &quot;start_ddmmyyyy, start_hhmmss, end_ddmmyyyy, end_hhmmss)&quot;

Sqlinsert = SqlInsert & &quot; values ('&quot; & rs(&quot;call_id&quot;) & &quot;', '&quot; & rs(&quot;start_date&quot;) & &quot;', '&quot;
Sqlinsert = SqlInsert & rs(&quot;end_date&quot;) & &quot;', '&quot; & rs(&quot;call_source&quot;) & &quot;', '&quot; & rs(&quot;call_destination&quot;) & &quot;', '&quot;
Sqlinsert = SqlInsert & rs(&quot;queue_duration&quot;) & &quot;', '&quot; & rs(&quot;ring_duration&quot;) & &quot;', '&quot; & rs(&quot;call_duration&quot;) & &quot;', '&quot;
Sqlinsert = SqlInsert & rs(&quot;clerical_duration&quot;) & &quot;', '&quot; & rs(&quot;enquiry_duration&quot;) & &quot;', '&quot; & rs(&quot;source_hold_duration&quot;) & &quot;', '&quot;
Sqlinsert = SqlInsert & rs(&quot;dest_hold_duration&quot;) & &quot;', '&quot; & rs(&quot;park_duration&quot;) & &quot;', '&quot; & rs(&quot;call_type&quot;) & &quot;', '&quot;
Sqlinsert = SqlInsert & rs(&quot;call_origin_type&quot;) & &quot;', '&quot; & rs(&quot;call_termination_type&quot;) & &quot;', '&quot; & rs(&quot;agent_id&quot;) & &quot;', '&quot;
Sqlinsert = SqlInsert & rs(&quot;agent_group&quot;) & &quot;', '&quot; & rs(&quot;src_agent_id&quot;) & &quot;', '&quot; & rs(&quot;queue_id&quot;) & &quot;', '&quot;
Sqlinsert = SqlInsert & rs(&quot;call_info&quot;) & &quot;', '&quot; & rs(&quot;tli_oli_digits&quot;) & &quot;', &quot;


'build logon date
var_day = datepart (&quot;d&quot;, rs(&quot;start_date&quot;))
var_month = datepart (&quot;m&quot;, rs(&quot;start_date&quot;))
var_year = datepart (&quot;yyyy&quot;, rs(&quot;start_date&quot;))

Var_month = monthname(var_month)

var_start_date = var_day & &quot; &quot; & var_month & &quot; &quot; & var_year


'logon date

sqlinsert = sqlinsert & &quot;'&quot; & var_start_date & &quot;', &quot;

'logon date
sqlinsert = sqlinsert & &quot;'&quot; & datepart(&quot;h&quot;, rs(&quot;start_date&quot;)) & &quot;:&quot; & datepart(&quot;n&quot;, rs(&quot;start_date&quot;)) & &quot;:&quot; & datepart(&quot;s&quot;, rs(&quot;start_date&quot;)) & &quot;', &quot;




'build logoff date
var_day = datepart (&quot;d&quot;, rs(&quot;end_date&quot;))
var_month = datepart (&quot;m&quot;, rs(&quot;end_date&quot;))
var_year = datepart (&quot;yyyy&quot;, rs(&quot;end_date&quot;))

var_month = monthname(var_month)


var_end_date = var_day & &quot; &quot; & var_month & &quot; &quot; & var_year


'end date
Sqlinsert = SqlInsert & &quot;'&quot; & var_end_date & &quot;', &quot;
'end time
Sqlinsert = SqlInsert & &quot;'&quot; & datepart(&quot;h&quot;, rs(&quot;end_date&quot;)) & &quot;:&quot; & datepart(&quot;n&quot;, rs(&quot;end_date&quot;)) & &quot;:&quot; & datepart(&quot;s&quot;, rs(&quot;end_date&quot;))& &quot;')&quot;



ConnWrite.Execute(&quot;Insert into CallRecordData &quot; & SQLinsert)

if err.number <> 0 then

ConnWrite.Execute(&quot;Insert into CallRecordDataErr &quot; & SQLinsert)
err.clear
end if
LPCount = LPCount + 1
Rs.movenext
loop
ConnWrite.close
set ConnWrite = nothing
end if
Rs.close
Conn.close
set Rs = nothing
set Conn = nothing


'**********************************************************************************************************************
'increment by one
varLOOP = varLOOP + 1

'end main loop
Loop
'**********************************************************************************************************************
'destroy connections
set Rs = nothing
set Conn = nothing
 
Your script doesn't appear to be MS SQL Server TSQL. Are you using MS SQL Server for the database? If not, then you are posting in the wrong forum.

-SQLBill
 
You should post this question in the ASP forum - forum333.

Also, try and avoid just dumping your entire code. What is the error you are getting on this page? What line does it occur on? If necessary, post the relevant code sections. --James
 
It's also kind of polite to avoid using all caps as that is the electronic equivalent of screaming.
 
What language is this? The first thing that looks odd to me is the colon after the &quot;else&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top