Hai,
Problem we are Facing Currently: Records getting inserted as only one during the process of updating the server.
Previously, all the given records get inserted into the database table during the updation process.
"updateprice" is the .mdb exists locally in the same folder where the calling file for updating records exists. It contains record data to be uploaded to the server database. It acts as an temporary storage database.
The records to be updated to the server are either in an notepad or excel. Whatever be the count in records, previously it was updated fine. "rsTextData.Update" is line 86. I'm blinking where it fails.The error which we're facing and the code is given below for the assistance.
Error Showing as
1 record(s) converted
File Name:DTRinggit081110Ringgit Extends Downtrend Against Greenback
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC SQL Server Driver][SQL Server]Violation of PRIMARY KEY constraint 'PK_text_data'. Cannot insert duplicate key in object 'text_data'.
/data_maintain/News.asp, line 86
Code Part
<table width="100%" cellspacing="0" cellpadding="0" align="center">
<tr><td height="25" class="mtext" background="../images/top_bar.jpg" align="center"><font color="#FFFFFF"><b>ADMINISTRATION</b></font></td></tr>
<tr><td height="10"></td></tr>
<tr><td height="20"></td></tr>
<tr><td width="100%" class="mtext">
<p style="margin-left: 10; margin-right: 3">
<center>
<b> Uploading Text Data in progress...<br>
<br>Please wait..</b>
</center>
<%
set myconn=server.createobject("ADODB.connection")
myconn.open "updateprice"
myconn.CommandTimeout=0
set rsData = Server.CreateObject ("ADODB.Recordset")
NewsCodeSelectSql="Select * from text_data"
set rsData=myconn.execute(NewsCodeselectsql)
code = 0
intRecCount = 0
set myconn1=server.createobject("ADODB.connection")
myconn1.open "DSN=commodities;uid=fbspl07;pwd=07#web&;"
myconn1.commandtimeout=0
Response.Write("1 record(s) converted<br>")
do while not rsdata.eof
Set cmdTemp=Server.CreateObject("ADODB.Command")
cmdTemp.CommandType=2
sql="select * from text_Data where 1<>1"
set rsTextData=Server.CreateObject("ADODB.Recordset")
rstextdata.locktype=adLockOptimistic
rsTextData.Open "select * from text_Data where 1<>1",myconn1
msgbox rsTextData.RecordCount
rsTextData.Addnew
response.write "File Name:" &rsdata(3)
'response.write "Title: " &rsdata(4)&"<br>"
rsTextData("Text_id")=rsdata(0)
rsTextData("Date1")=rsdata(1)
rsTextData("Comname_id")=rsdata(2)
rsTextData("Filename")=rsdata(3)
'response.write "Title= " & rsdata(4) &"<br>"
title1=replace(rsdata(4),"("," ")
title1=replace(title1,")"," ")
title1=replace(title1,":","-")
response.write title1
'response.end
rsTextData("Title")=title1
'rsTextData("Title")= rsdata(4)
rsTextData("Source")=rsdata(5)
rsTextData("isspot")=rsdata(6)
rsTextData("Module_type")=rsdata(7)
rsTextData("Submodule_type")=rsdata(8)
rsTextData("Time1")=time()
rsTextData.Update
rsTextData.close
rsData.movenext
code = code + 1
If code mod 25 = 0 then
Response.Write(code &" records converted<br>")
end If
loop
response.WRITE("<br><br><b> Text Data is Inserted Successfully....</b><br><br>")
%>
<p align="RIGHT"><a href="javascript:history.back()" target="_parent"><font face="Arial" size="2">Back</font></a>
</td></tr>
<tr><td height="20"></td></tr>
</table>
M.Sworna Vidhya