Click here to Skip to main content
15,891,136 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: how to solve this error ------>Access to the path 'C:\websites\afxisi.org\Export\contacts.csv' is denied ? Pin
Ranjit Viswakumar3-Feb-09 3:26
Ranjit Viswakumar3-Feb-09 3:26 
QuestionBackup and Restore database using xml Pin
RajaAhmed2-Feb-09 19:38
RajaAhmed2-Feb-09 19:38 
AnswerRe: Backup and Restore database using xml Pin
N a v a n e e t h2-Feb-09 19:43
N a v a n e e t h2-Feb-09 19:43 
GeneralRe: Backup and Restore database using xml Pin
RajaAhmed2-Feb-09 22:10
RajaAhmed2-Feb-09 22:10 
QuestionHow to set desired selected index of dropdownlist having AutoPostBack=true Pin
Dattatraya K2-Feb-09 19:35
Dattatraya K2-Feb-09 19:35 
AnswerRe: How to set desired selected index of dropdownlist having AutoPostBack=true Pin
Abhijit Jana2-Feb-09 20:22
professionalAbhijit Jana2-Feb-09 20:22 
GeneralRe: How to set desired selected index of dropdownlist having AutoPostBack=true Pin
Dattatraya K2-Feb-09 20:47
Dattatraya K2-Feb-09 20:47 
Questionerror "There is already an open DataReader associated with this Command which must be closed 1st." Pin
Eunice (VB junior)2-Feb-09 19:03
Eunice (VB junior)2-Feb-09 19:03 
Hi ladies and gentlmen,
I got this error while doing the transactions insert command in a do loop select command.
What I'm trying to do is, 1st to run select command to query filename and filesize (it consists of few results).
Then with the retrieved results, rename the filename and insert into another table with the new filename.
After that delete it from the original table.
But i got this error "There is already an open DataReader associated with this Command which must be closed 1st".

How can i overcome this?can anyone help me on this? I'm out of ideas. Thanks and appreciate...

Here is my code:-
cmd.Connection = cn
cn.Open()
tn = cn.BeginTransaction
cmd.Transaction = tn

strQuery2 = "SELECT FileName,FileSize FROM udtTempAttach where UniqueID = '" & Me.lblUniqueID.Text & "'"
cmd.CommandText = strQuery2
dr2 = cmd.ExecuteReader
Try
Do While dr2.Read
filename = Replace(dr2(0).ToString, ".", "_" & DistID & ".")
filesize = dr2(1).ToString
FileIO.FileSystem.CopyFile(ServerPath + "TempAttach\" + dr2(0).ToString, ServerPath + "Attachment\" + filename, True)
If FileIO.FileSystem.FileExists(ServerPath + "Attachment\" + filename) Then
FileIO.FileSystem.DeleteFile(ServerPath + "TempAttach\" + dr2(0).ToString)
End If

strQuery3 = "INSERT udtAttachment (DistID,FileName,FileSize,EnterDate) "
strQuery3 = strQuery3 & " values('" & DistID.ToString & "','" & filename.ToString & "','" & filesize.ToString & "',getdate()) "
cmd.CommandText = strQuery3
ra = cmd.ExecuteNonQuery()

strQuery3 = "Delete from udtTempAttach where UniqueID='" & Me.lblUniqueID.Text & "' and filename = '" & dr2(0).ToString & "'"
cmd.CommandText = strQuery3
ra = cmd.ExecuteNonQuery()

Loop

dr2.Close()
Catch ex As Exception
MsgBox(ex.Message)
dr2.Close()
tn.Rollback()

Finally
If cn.State = ConnectionState.Open Then cn.Close()
End Try

.......Thanks.......
AnswerRe: error "There is already an open DataReader associated with this Command which must be closed 1st." Pin
N a v a n e e t h2-Feb-09 19:13
N a v a n e e t h2-Feb-09 19:13 
AnswerRe: error "There is already an open DataReader associated with this Command which must be closed 1st." Pin
Christian Graus2-Feb-09 19:13
protectorChristian Graus2-Feb-09 19:13 
GeneralRe: error "There is already an open DataReader associated with this Command which must be closed 1st." Pin
Eunice (VB junior)2-Feb-09 19:25
Eunice (VB junior)2-Feb-09 19:25 
GeneralRe: error "There is already an open DataReader associated with this Command which must be closed 1st." Pin
N a v a n e e t h2-Feb-09 19:26
N a v a n e e t h2-Feb-09 19:26 
GeneralRe: error "There is already an open DataReader associated with this Command which must be closed 1st." Pin
Eunice (VB junior)2-Feb-09 19:28
Eunice (VB junior)2-Feb-09 19:28 
QuestionTreeview Pin
samrat.net2-Feb-09 19:00
samrat.net2-Feb-09 19:00 
AnswerRe: Treeview Pin
Christian Graus2-Feb-09 19:14
protectorChristian Graus2-Feb-09 19:14 
GeneralRe: Treeview Pin
samrat.net2-Feb-09 19:26
samrat.net2-Feb-09 19:26 
QuestionHow to hook up events inside a template Pin
threemp32-Feb-09 18:39
threemp32-Feb-09 18:39 
AnswerRe: How to hook up events inside a template Pin
N a v a n e e t h2-Feb-09 18:53
N a v a n e e t h2-Feb-09 18:53 
QuestionProblem with creating a web project Pin
reogeo20082-Feb-09 17:57
reogeo20082-Feb-09 17:57 
AnswerRe: Problem with creating a web project Pin
N a v a n e e t h2-Feb-09 18:28
N a v a n e e t h2-Feb-09 18:28 
GeneralRe: Problem with creating a web project Pin
reogeo20082-Feb-09 18:47
reogeo20082-Feb-09 18:47 
GeneralRe: Problem with creating a web project Pin
N a v a n e e t h2-Feb-09 18:51
N a v a n e e t h2-Feb-09 18:51 
GeneralRe: Problem with creating a web project Pin
reogeo20083-Feb-09 2:41
reogeo20083-Feb-09 2:41 
GeneralRe: Problem with creating a web project Pin
The_Collector4-Feb-09 2:17
The_Collector4-Feb-09 2:17 
QuestionHow to make the html row visible and hidden? Pin
meeram3952-Feb-09 17:43
meeram3952-Feb-09 17:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.