How To Fix This Error? (There Is Already An Open DataReader Associated With This Command Which Must Be Closed First.)

Jun 26, 2007

This is my code:1 If Session("ctr") = False Then
2
3 Connect()
4
5 SQL = "SELECT * FROM counter"
6 SQL = SQL & " WHERE ipaddress='" & Request.ServerVariables("REMOTE_ADDR") & "'"
7 dbRead()
8
9 If dbReader.HasRows = True Then
10
11 dbReader.Read()
12 hits = dbReader("hits")
13 hits = hits + 1
14 dbClose()
15
16 SQL = "UPDATE counter SET hits=" & hits
17 SQL = SQL & " WHERE ipaddress='" & Request.ServerVariables("REMOTE_ADDR") & "'"
18 dbExecute()
19
20 Else
21
22 SQL = "INSERT INTO counter(ipaddress,hits)"
23 SQL = SQL & " VALUES('" & Request.ServerVariables("REMOTE_ADDR") & "',1)"
24 dbExecute()
25
26 End If
27
28 Session("ctr") = True
29
30 End If
 1 Public Sub Connect()
2 Conn = New SqlConnection("Initial Catalog=NURSETEST;User Id=sa;Password=sa;Data Source=KSNCRUZ")
3 If Conn.State = ConnectionState.Open Then
4 Conn.Close()
5 End If
6 Conn.Open()
7 End Sub
8
9 Public Sub Close()
10 Conn.Close()
11 Conn = Nothing
12 End Sub
13
14 Public Sub dbExecute()
15 dbCommand = New SqlCommand(SQL, Conn)
16 dbCommand.ExecuteNonQuery()
17 End Sub
18
19 Public Sub dbRead()
20 dbCommand = New SqlCommand(SQL, Conn)
21 dbReader = dbCommand.ExecuteReader
22 End Sub
23
24 Public Sub dbClose()
25 SQL = ""
26 dbReader.Close()
27 End Sub
 

View 2 Replies


ADVERTISEMENT

There Is Already An Open DataReader Associated With This Command Which Must Be Closed

Oct 15, 2007

I have gathered from reading online that I need to create a 2nd connection to SQL Server if I want to insert records into the database while in a "while (reader.Read())" loop.

I am trying to make my code as generic as possible, and I don't want to have to re-input the connection string at this point in my code. Is there a way to generate a new connection based on the existing open one? Or should I just create 2 connections up front and carry them around with me like I do for the 1 connection now?

Thanks.

View 7 Replies View Related

Exception:There Is An Open DataReader Associated With This Command Which Must Be Closed First.

May 3, 2008

the class code:
Dataase.cs: using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Xml.Linq; using System.Data.SqlClient; using System.Data.Common; using System.Web; /// <summary> /// Summary description for DataBase /// </summary> public class DataBase { private SqlConnection con=new SqlConnection(); private void Open() { if (con==null) { con = new SqlConnection("Data Source=58.17.30.81;Initial Catalog=a1230192748;Persist Security Info=True;User ID=a1230192748;Password=***"); } if (con.State == System.Data.ConnectionState.Closed) { con.ConnectionString = "Data Source=58.17.30.81;Initial Catalog=a1230192748;Persist Security Info=True;User ID=a1230192748;Password=****"; con.Open(); } } public void Close() { if (con != null && con.State != System.Data.ConnectionState.Open) con.Close(); } public DataBase() { // // TODO: Add constructor logic here // } public string liuyan(string id,string sign) { string com=string.Empty; switch(sign) { case "xiaobiaoti": com="Select subject from liuyan where liuyanid='"+id+"'"; break; case "def_message": com="Select message from liuyan where liuyanid='"+id+"'"; break; } SqlCommand myCommand=new SqlCommand(com,con); Open(); try { SqlDataReader sdr=myCommand.ExecuteReader(); if (sdr.Read()) { return sdr[0].ToString(); } else { return ""; } sdr.Close();    //what i have written.} catch (Exception ex) { HttpContext.Current.Response.Write("<script>alert('error:" + ex.Message + "')</script>"); return ""; } finally { myCommand.Dispose(); Close(); } } }
 
it was instantiated once in  aspx.cs code.I invoke liuyan(string id,string sign) twice.The first one is OK and the second one makes an exception.
 

View 3 Replies View Related

Error: There Is Already An Open DataReader Associated With This Command

Nov 1, 2006

HiI'm trying to loop through all the records in a recordset and perform a database update within the loop. The problem is that you can't have more than one datareader open at the same time. How should I be doing this? cmdPhoto = New SqlCommand("select AuthorityID,AuthorityName,PREF From qryStaffSearch where AuthorityType='User' Order by AuthorityName", conWhitt)conWhitt.Open()dtrPhoto = cmdPhoto.ExecuteReaderWhile dtrPhoto.Read()If Not File.Exists("D:WhittNetLiveWebimagesstaffphotospat_images_resize" & dtrPhoto("PRef") & ".jpg") ThencmdUpdate = New SqlCommand("Update tblAuthority Set NoPhoto = 1 Where AuthorityID =" & dtrPhoto("AuthorityID"), conWhitt)cmdUpdate.ExecuteNonQuery()End IfEnd WhileThanks

View 7 Replies View Related

Open DataReader Error

Apr 16, 2008

Looking at the below code you can see that I have a separate Connection for each Insert Statement.'OPEN CONNECTION TO ESOSQL
MyConnection = New SqlConnection("......")
MyConnection.Open()

'check if there are existing charges for this person. The user must enter in atleast 1 charge before proceeding with arrest insert.
MyCheck = New SqlCommand("SELECT * FROM ARREST_CHARGES WHERE ARRESTNO = '" & Session("uid") & "'", MyConnection)
MyCheck.CommandType = CommandType.Text
MyDataReader = MyCheck.ExecuteReader

If MyDataReader.HasRows Then

MyConnection1 = New SqlConnection("...")
MyConnection1.Open()

MyInsert = New SqlCommand("INSERT INTO ARREST_INDEX (ARRESTNO, NOTES) VALUES ('" & Session("uid") & "','" & tx_notes.Text & "')", MyConnection1)

MyInsert.CommandType = CommandType.Text
MyInsert.ExecuteNonQuery()

MyConnection1.Close()

MyConnection2 = New SqlConnection("....")
MyConnection2.Open()

MyOtherInsert = New SqlCommand("INSERT INTO ARREST_COMMENTS (ARRESTNO, NOTES) VALUES ('" & Session("uid") & "','" & tx_notes.Text & "')", MyConnection2)

MyOtherInsert.CommandType = CommandType.Text
MyOtherInsert.ExecuteNonQuery()

MyConnection2.Close()

Label1.Text = ""
Else
div1.Style.Add("display", "block")
Label1.Text = "You must enter charges before proceeding."
End If
MyConnection.Close()One would think I should only have to use one connection. However, if I use only one I get this error:There is already an open DataReader associated with this Command which must be closed first. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.Source Error: Line 60:
Line 61: MyInsert.CommandType = CommandType.Text
Line 62: MyInsert.ExecuteNonQuery()
Line 63:
Line 64: ' MyConnection1.Close()The only way I could get rid of it was to encapsulate each individual INSERT statement within its own connection. This seems to me as very inefficient. Can anyone explain why I couldn't just use one connection?Thanks.

View 5 Replies View Related

Already Open DataReader Error

Jan 9, 2007

I am getting the following error when running some of my reports that use a Report Model on a recently built Windows 2003 R2 server with SQL Server 2005 SP2 intalled. The reports run fine our SQL Server 2005 RTM server.



W3wp!webserver!7!01/09/2007-12:57:58:: e

ERROR: Reporting Services

error Microsoft.ReportingServices.Diagnostics.Utilities.RSException:

An error has occurred during report processing. ---> Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: An error has occurred during report processing. ---> System.InvalidOperationException:

There is already an open DataReader associated with this Command which must be closed first.

Any help would be appreciated.

Rick

View 2 Replies View Related

Open Datareader

May 2, 2008

"There is already an open datareader associated with this command which must be closed first." 
I have received this same error before, but I'm not sure why I'm getting it here.'Create a Connection object.
MyConnection = New SqlConnection("...............................")

'Check whether a TMPTABLE_QUERY stored procedure already exists.
MyCommand = New SqlCommand("...", MyConnection)

With MyCommand
'Set the command type that you will run.
.CommandType = CommandType.Text

'Open the connection.
.Connection.Open()

'Run the SQL statement, and then get the returned rows to the DataReader.
MyDataReader = .ExecuteReader()

'Try to create the stored procedure only if it does not exist.
If Not MyDataReader.Read() Then
.CommandText = "create procedure tmptable_query as select * from #temp_table"

MyDataReader.Close()
.ExecuteNonQuery()
Else
MyDataReader.Close()
End If

.Dispose() 'Dispose of the Command object.
MyConnection.Close() 'Close the connection.
End With
As you can see, the connection is opened and closed, and the datareader is closed.   Here's what comes next...'Create another Connection object.
ESOConnection = New SqlConnection("...")

If tx_lastname.Text <> "" Then
If (InStr(sqlwhere, "where")) Then
sqlwhere = sqlwhere & " AND lname like '" & Replace(tx_lastname.Text, "'", "''") & "%'"
Else
sqlwhere = " where lname like '" & Replace(tx_lastname.Text, "'", "''") & "%'"
End If
End If
If tx_firstname.Text <> "" Then
If (InStr(sqlwhere, "where")) Then
sqlwhere = sqlwhere & " AND fname like '" & Replace(tx_firstname.Text, "'", "''") & "%'"
Else
sqlwhere = " where fname like '" & Replace(tx_firstname.Text, "'", "''") & "%'"
End If
End If

dynamic_con = sqlwhere & " order by arr_date desc "

'create the temporary table on esosql.
CreateCommand = New SqlCommand("CREATE TABLE #TEMP_TABLE (".............", ESOConnection)

With CreateCommand
'Set the command type that you will run.
.CommandType = CommandType.Text

'Open the connection to betaserv.
ESOConnection.Open()

'Run the SQL statement.
.ExecuteNonQuery()

End With

'query our side
ESOCommand = New SqlCommand("SELECT * FROM [arrest_index]" & dynamic_con, ESOConnection)

'execute query
ESODataReader = ESOCommand.ExecuteReader()

'loop through recordset and populate temp table
While ESODataReader.Read()

MyInsert = New SqlCommand("INSERT INTO #TEMP_TABLE VALUES("......", ESOConnection)

'Set the command type that you will run.
MyInsert.CommandType = CommandType.Text

'Run the SQL statement.
MyInsert.ExecuteNonQuery()

End While

ESODataReader.Close()  'Create a DataAdapter, and then provide the name of the stored procedure.
MyDataAdapter = New SqlDataAdapter("TMPTABLE_QUERY", ESOConnection)

'Set the command type as StoredProcedure.
MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure

'Create a new DataSet to hold the records and fill it with the rows returned from stored procedure.
DS = New DataSet()
MyDataAdapter.Fill(DS, "arrindex")

'Assign the recordset to the gridview and bind it.
If DS.Tables(0).Rows.Count > 0 Then
GridView1.DataSource = DS
GridView1.DataBind()
End If

'Dispose of the DataAdapter
MyDataAdapter.Dispose()

'Close server connection
ESOConnection.Close() Again, a separate connection is open and closed.I've read you can only have 1 datareader available per connection. Isn't that what I have here? The error is returned on this line: MyInsert.ExecuteNonQuery()
Help is appreciated.
 

View 3 Replies View Related

Closed Transaction Keeps Running...awaiting Command

Jul 20, 2005

I am debugging an app which blocks many processes in a SQL7 server DB.The app log writes every transaction "open" and "close".The weird thing is : when the app logfile says the transaction isdropped (object closed) the db keeps showing the process "running", ina sleeping mode, with open_tran in 2 or even 3 and in an awaitingcommand status.We are working on NT4.0, SP6a (all fixes up to date, MDAC 2.7SP1) onIIS side, an equal box for MTS (same patches and updates) and a SQLServer 7 (on NT4, same fixes ans SPs) database on another box.Is this normal? Those sleeping processes are blocking other apps andeverything gets slow and messy....the only solution is to kill thoseblocking processes.Thanks!

View 1 Replies View Related

ExecuteNonQuery While DataReader Still Open

Aug 1, 2004

Hi all!

I basically need to get some records from a table and while looping through them i need to insert some records on other table.

I keep getting this error:

There is already an open DataReader associated with this connection which must be closed first.

The piece of code that I have is like this:


...
SqlCommand sqlCmd2 = new SqlCommand(sqlString2, dbConn);
sqlCmd2.Transaction = trans;
SqlDataReader dr = sqlCmd2.ExecuteReader(CommandBehavior.CloseConnection);

//loop through dr
while (dr.Read())
{
string sqlStr = "insert into prodQtyPrice (typeQtyId, prodId, typeId) values(28," + dr["prodId"] + "," + dr["typeId"] +")";
SqlCommand sqlCmd3 = new SqlCommand(sqlStr, dbConn);
//sqlCmd3.Transaction = trans;
sqlCmd3.ExecuteNonQuery();
}
...


Also I would like to have the insertions in the same transaction as the previous sql commands.

Thanks a million!

LAM

View 4 Replies View Related

How To Open A Second Connection While In A Datareader

Dec 13, 2007



Hi,

I hope someone can help me with this.

I have created a data reader to loop thru a table and build an update statement.
Now I need to execute this statement in the datareader loop but the connection object is in use.

I tried creating another connection object but get an error:
"The context connection is already in use."

Is there a way to open another connection while the main context connection is open.
Just to make it clear, I do not want to read all the rows into memory first and then call update, it has to
happen for each iteration of the datareader.

Thanks.
--
With Regards
Shailen Sukul
Software Architect/Developer/Consultant
(BSc | Mcts (Biztalk (IP)) | Mcpd | Mcts (Web, Win, Dist Apps) | Mcsd.NET | Mcsd | Mcad)
Ashlen Consulting Services Pty Ltd
(http://www.ashlen.com.au)
MSN | Skype | GTalk Id: shailensukul
Ph: +61 0421 277 812
Fax: +61 3 9011 9732
Linked In: http://www.linkedin.com/in/shailensukul

View 7 Replies View Related

SQL Command Datareader

Jul 31, 2007

I have the following SQL statement in the DataReader.SQLCommand.

select * from myTable where DataEdited > 'some hard coded date data'

I want to read the above 'some hard coded date data' from a table sitting in different database which is not the same server where the DataReader is connected.

How to do that?

I can populate the 'some hard coded date data' to a SSIS variable but do not know how to embed that in the SQL statement.

Thank you for your thoughts.

Smith

View 9 Replies View Related

Datareader Can Not Open Connection To My Database For Login Myusername

Feb 1, 2007

  This is my page_loads event code and iam getting the Exception pasted below the code.
-----------------------------------------------------------------------------------------------------------------------------------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not Page.IsPostBack Then
Dim myconnection As New SqlConnection("Data Source=localhostSQLEXPRESS;initial catalog = safetydata.mdf;Integrated Security=True;User Instance=True")
Dim strSQL As String = "SELECT Incident_Id,Emp_No From Report_Incident"
Dim mycommand As New SqlCommand(strSQL, myconnection)
myconnection.Open()
Dim reader As SqlDataReader = mycommand.ExecuteReader()
 
Dim chart As New PieChart
chart.DataSource = reader
chart.DataXValueField = "Incident_id"
chart.DataYValueField = "Emp_No"
chart.DataBind()
 
chart.DataLabels.Visible = True
 
ChartControl1.Charts.Add(chart)
ChartControl1.RedrawChart()
myconnection.Open()
 
End If
End Sub
 -------------------------------------------------------------------------------------------------------------------------------
EXCEPTION IS BELOW
Cannot open database "mydatabase.mdf" requested by the login. The login failed.Login failed for user 'myusername'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Cannot open database "safetydata.mdf" requested by the login. The login failed.Login failed for user 'myusername'.Source Error:



Line 18: Dim strSQL As String = "SELECT Incident_Id,Emp_No From Report_Incident"
Line 19: Dim mycommand As New SqlCommand(strSQL, myconnection)
Line 20: myconnection.Open()
Line 21: Dim reader As SqlDataReader = mycommand.ExecuteReader()
Line 22: Source File: C:Incident Reporting System--Trial VersionWebChart.aspx    Line: 20 Stack Trace:



[SqlException (0x80131904): Cannot open database "safetydata.mdf" requested by the login. The login failed.
Login failed for user 'myusername'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +171
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2305
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +34
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +606
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +193
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +501
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +429
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +70
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +512
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +85
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +89
System.Data.SqlClient.SqlConnection.Open() +160
ASP.webchart_aspx.Page_Load(Object sender, EventArgs e) in C:Incident Reporting System--Trial VersionWebChart.aspx:20
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +45
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3745



Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.

View 1 Replies View Related

Connection, DataReader And Command Question

Apr 2, 2008

I have a multiple form project for a Windows CE 5.0 device (Symbol MC3000) written in VB.NET (Visual Studio 2005) using SQL Server Compact 3.5.

If I create the database on the SD Card, the program works fine until the unit is "suspended". When the power resumes, I can still continue to work and save/access data in the database as long as I do not go to another form. If I go to another form, I get an access violation error (0xC0000005).

If the database is installed in main memory the prorgam works properly even after the power is cycled.

Unfortunately, due to the memory size restrictions on the device, there are cases where the database needs to be stored on the SD Card.

Currently the program uses a single "global" SQLCeConnection and the connection is closed prior to the device being powered off. However, each procedure/event in the program uses it's own SQLCeCommand and SQLCeDataReader objects (which are created and closed/disposed prior to the end of the procedure).

I have tried everything I can think of, including OS updates, .NET Compact Framework 2.0 updates and modifications to the program to correct this, but the results are the same.

Would creating a global SQLDataReader and SQLCeCommand object help with this issue or should the way that this is currently being handled work?

View 4 Replies View Related

ExecuteReader Requires An Open And Available Connection. The Connection's Current State Is Closed.

Apr 26, 2007

I am accessing SQL2005 with C# code using OleDbConnection.



A try and catch block catches the following error once a while between the Open() and Close() of the connection:

ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.



I do not even have any idea where to start to debug this. The ExecuteNonQuery() runs a delete SQL query. It works 99.9% of the time. I do not see anything wrong when this error happens.



Any hint would be greatly appreciated.



View 9 Replies View Related

The Underlying Connection Was Closed: An Unexpected Error Occurred On A Receive. Endpoint Error

Mar 28, 2007

what can cause the above error when connecting to an endpoint via a c# app? the app, and sql are both on my machine ( im just doing this for test purposes and to learn something new.)

View 1 Replies View Related

Large Reports - Error: The Underlying Connection Was Closed: An Unexpected Error Occurred On A Receive.

Mar 13, 2008

First off I understand that it is a horrible idea to run extremely large/long running reports, but sometimes it ends up being the best possible solution due to external forces.




I've got a 25,000 page report that we recently converted from crystal reports to SSRS. The SSRS server is a 64bit 2003 server with 32 gigs of ram running SSRS 2005. When running the report through the report manager web application, it renders in the browser/viewer after about 12 minutes. Exporting to pdf through the browser/viewer in the report manager takes an additional 55 minutes. It does work and it produces a whopping 1.03gb pdf.




Unfortunately, I've run into a problem when trying to do this from a console application using the SSRS client API. After about 30-35 minutes I get an exception on the client with the following error:
Exception Message: The underlying connection was closed: An unexpected error occurred on a receive.
InnerException = Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

Here is the api call:




Code Snippet

byte[] m_data = reportingService.Render(this.ReportPath, this.ExportFormat, null,
deviceInfo, selectedParameters, null, null, out encoding, out m_mimeType,

out usedParameters, out warnings, out streamIds);
Here are some things I've tried so far:


set the HttpRuntime ExecutionTimeout value to 3 hours on the report server
disabled http keep alives on the report server
increased the script timeout on the report server
set the report to never time out on the server
set the report timeout to several hours on the client call
Disabled antivirus on the client side, and verified there was no antivirus running on the reporting server.
Tried using default credentials in the ReportingService object as opposed to supplying credentailsAny ideas would be appreciated. I understand the best solution is to split the report up into smaller reports, which is the backup option, but being able to keep it as one report is the goal.

View 1 Replies View Related

Object Closed Error

May 3, 2006

I'm getting object closed when returning a recordset from a stored procedure. I've tested the select statement in Query Analyzer and a value is getting returned. So, I'm not sure if my code for my stored procedure is incorrect?

Here is the code for the procedure:

CREATE Procedure dbo.GetRepEmailByZip

@sessionid varchar(50),
@zip varchar(5)

AS

Begin Transaction

INSERT INTO dbo.SupportRequests(firstname,lastname,schoolname, address,city,state,zip,phone,email,currentcustomer ,implementationtype,producttype,comment)
(SELECT FirstName,LastName,SchoolName,Address,City,State,Z ip,Phone,Email,CurrentCustomer,ImplementationType, ProductType,Comment
FROM dbo.Temp_ContactInfo
WHERE sessionid = @sessionid)


--If Transacation fails, stop execution of procedure, return error code and Rollback Transaction

IF @@ERROR<>0 OR @@RowCount = 0
BEGIN
ROLLBACK TRANSACTION
--return value
RETURN 1
END

--If Transaction succeeds, commit transaction, continue and process the select statement
COMMIT TRANSACTION

SELECT r.email
FROM PostalCodes p
INNER JOIN TerritoryList z ON p.ZipID = z.ZipID
INNER JOIN RepList r ON r.RepID = z.RepID
WHERE p.ZipCode = @zip
GO



This is the code I'm calling to execute the procedure and return the recordset:


set GetRepEmail = Server.CreateObject("ADODB.Command")
With GetRepEmail
.ActiveConnection = MM_DBConn_STRING
.CommandText = "dbo.GetRepEmailByZip"
.CommandType = 4
.CommandTimeout = 0
.Prepared = true
.Parameters.Append .CreateParameter("@RETURN_VALUE", 3, 4)
.Parameters.Append .CreateParameter("@sessionid", 200, 1,50,usrid)
.Parameters.Append .CreateParameter("@zip", 200, 1,5,zip)
set RepEmail = .Execute()
End With

Dim x, y
x = RepEmail.RecordCount
y = RepEmail.State
Response.Write(x)
Response.Write("<br>")
Response.Write(y)
'Response.Write(RepEmail("email"))
Response.End()


I'm getting "Operation is not allowed when the object is closed", which is occuring on the following line:

x = RepEmail.RecordCount

I'm trying to determine if this is problem within my procedure or in the application code.

Thanks in advance for any help.

View 4 Replies View Related

DataReader Source - ERROR [42000] XML Parse Error At 162:1338: Not Well-formed (invalid Token)

Apr 1, 2008



Hello, I get the following error when I run my package interactively. From the logs written out by the driver, it appears that all is working well as far as connecting to the data source and pulling data. It seems as if this error occurs when the DataReader source tries to process the received data.

SSIS package "MyPackage.dtsx" starting.
Information: 0x4004300A at Data Flow Task, DTS.Pipeline: Validation phase is beginning.
Information: 0x40043006 at Data Flow Task, DTS.Pipeline: Prepare for Execute phase is beginning.
Information: 0x40043007 at Data Flow Task, DTS.Pipeline: Pre-Execute phase is beginning.
Error: 0xC0047062 at Data Flow Task, DataReader Source [1]: System.Data.Odbc.OdbcException: ERROR [42000] XML parse error at 162:1338: not well-formed (invalid token)
at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
at System.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Odbc.OdbcCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.SqlServer.Dts.Pipeline.DataReaderSourceAdapter.PreExecute()
at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostPreExecute(IDTSManagedComponentWrapper90 wrapper)
Error: 0xC004701A at Data Flow Task, DTS.Pipeline: component "DataReader Source" (1) failed the pre-execute phase and returned error code 0x80131937.
Information: 0x40043009 at Data Flow Task, DTS.Pipeline: Cleanup phase is beginning.
Information: 0x4004300B at Data Flow Task, DTS.Pipeline: "component "OLE DB Destination" (691)" wrote 0 rows.
Task failed: Data Flow Task
SSIS package "MyPackage.dtsx" finished: Success.


I am not sure where to look next. Any help is much appreciated.

Dave

View 4 Replies View Related

How To Open Enterprise Manager Using Command Promp

Sep 21, 2006

how to open enterprise manager using keyboard shortcut?
and how to open enterprise manager using command prompt?

Regards
Satish

View 4 Replies View Related

EM Error 'connection Forcibly Closed By The Remote Host' (ouch)

Jul 22, 2005

I am getting this error in Enterprise Manager:
TCP Provider: An existing connection was forcibly closed by the remote host.

But, my web app can still connect just fine to the db, so it's still in
the same place with the same login/password.  And my registration
in EM was working just fine (for years) until yesterday I got this
error.  I've tried deleting the registration and re-creating it
but the same thing.  What could have gone wrong to cause this to
happen? 

Thanks for any pointers, I have no idea where to start looking on this one, the host says they haven't changed anything...

View 1 Replies View Related

Sql Server Reporting Services Error The Underlying Connection Was Closed

Sep 18, 2007



Hi,


We have a mature instance of SQL Server 2000 reporting services that has stopped working for no apparent reason. When browsing to http://reportserver/reports we receive the following error



Error



The underlying connection was closed: Unable to connect to the remote server.



Home

The installation is running on three servers - 1 sql cluster (sql 2000 sp4) and two IIS servers all running windows 2000 sp4.

The Reportserver website runs using identity impersonation using the .net machine.config file pointing to an encrypted registry key entry holding the userid and password. It has been moved from the default website to it's own website but has been working with no issues for years. No obvious patches have been applied or security changes made that could effect the application


When browsing to http://reportserver/reportserver we can view the loaded reports and even run them with no issues, only ther report manager isn't working.

I have tried changing the impersonation registry key ( using aspnet_setreg ) and the account the reportserver web service runs under ( using the rsconfig utiltity) to be a domain admin to no effect and I have checked and set specififc permission for the reportserver database on all registry keys to no effect.

None of the online solutions for this issue have worked for me. Any help or ideas would be greatly appreciated


Cheers


Daniel Worby

Database Administrator

AMP Capital Investors

(p) +61 2 9257 1746

(m)+61 434 327 150

(f) + 61 2 9257 1090

(e) daniel.worby@ampcapital.com

(w) www.ampcapital.com.au

View 1 Replies View Related

Message Could Not Be Delivered Because The Conversation Endpoint Has Already Closed Error In Profiler

Oct 12, 2007



Hi,

I already had a thread for same problem but didn't recieved any response in last 4-5 months so I created a new thread for this



I am using service broker in between two database servers. following is the way i am sending and receiving messages



Send



BEGIN TRAN
BEGIN DIALOG CONVERSATION @handle
FROM SERVICE @SendService
TO SERVICE @ReceiveService
ON CONTRACT @Contract
WITH LIFETIME = @lifetime;

SEND ON CONVERSATION @handle
MESSAGE TYPE @xmlMessageType(@xmlMessage);
COMMIT



Receive



BEGIN TRAN;
RECEIVE TOP(1) @xmlMessage = message_body,
@handle = conversation_handle,
@message_type = message_type_name
FROM TransactionQueue;

----------------------------------------------------------------------------------------------------
-- Check to make sure a message was returned to process. In theory this should never happen.
----------------------------------------------------------------------------------------------------
IF @@rowcount = 1
BEGIN

IF @message_type = 'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'
BEGIN
END CONVERSATION @handle;
COMMIT
RETURN 0
END

IF @message_type = N'http://schemas.microsoft.com/SQL/ServiceBroker/Error'
BEGIN
RAISERROR(N'Received error %s from service [Target]', 10, 1)
END CONVERSATION @handle;
COMMIT
RETURN 0
END


SET @sql = 'EXEC '+@message_processor_name+' @xml'

BEGIN TRAN
EXEC sp_executesql @sql, N'@xml XML', @xml=@xmlMessage
COMMIT TRAN
END CONVERSATION @handle;
END
COMMIT



I see Messages are delivered to the target every thing working fine other than following errors which i am seeing in profiler.



1) "This message could not be delivered because the conversation endpoint has already been closed." I see this error on initiator end. Is it like ending conversation on initiator end when i get "EndDialog" send an acknowledgement, which cannot be recieved by target as it has already ended conversation.



2) "An error occurred while receiving data: '64(The specified network name is no longer available.)'." I don't have much idea about the reason for this error. But in profiler i see value for GUID is different for this error and the real message.



Let me know if you need any other information

View 2 Replies View Related

Open Transaction With Sleeping Status And Wait Type As AWAITING COMMAND

Sep 4, 2015

During our DR drill we found that the same code which used to run perfectly fine on our Primary Data Centre is running very slow on Disaster Recovery DB Server and there are Lot's of open transaction with sleeping status and waittype as 'AWAITING COMMAND'.CPU, Memory and disk utilization are good. The ping reply between the app server and the DB server is well within the limit's even blocking is not their, also nothing is reported in the error logs. We are using SQL server 2014 STD 64 BIT on Windows Server 2012.

View 6 Replies View Related

Using A Variable In SSIS - Error - Command Text Was Not Set For The Command Object..

Nov 4, 2006

Hi All,

i am using a OLE DB Source in my dataflow component and want to select rows from the source based on the Name I enter during execution time. I have created two variables,

enterName - String packageLevel (will store the name I enter)

myVar - String packageLevel. (to store the query)

I am assigning this query to the myVar variable, "Select * from db.Users where (UsrName = " + @[User::enterName] + " )"

Now in the OLE Db source, I have selected as Sql Command from Variable, and I am getting the variable, enterName,. I select that and when I click on OK am getting this error.

Error at Data Flow Task [OLE DB Source [1]]: An OLE DB error has occurred. Error code: 0x80040E0C.
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E0C Description: "Command text was not set for the command object.".

Can Someone guide me whr am going wrong?

myVar variable, i have set the ExecuteAsExpression Property to true too.

Please let me know where am going wrong?

Thanks in advance.








View 12 Replies View Related

TCP Provider, Error: 0 - An Existing Connection Was Forcibly Closed By The Remote Host

Apr 29, 2006

We are getting a problem when the below error Log

Server: SQL Server 2005 and SP1.



Then, All the Web Servers will drop all connections and stop the network service. Later, the network service will start up automatically but all the before service is dropped.

We would like to know the error coming from?



Error Log

================

TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host



Event Type: Warning
Event Source: ASP.NET 2.0.50727.0
Event Category: Web Event
Event ID: 1309
Date: 4/29/2006
Time: 10:48:47 AM
User: N/A
Computer: 88DBWEB0
Description:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 4/29/2006 10:48:47 AM
Event time (UTC): 4/29/2006 2:48:47 AM
Event ID: 77910e6688484582bb1c29808feef883
Event sequence: 128
Event occurrence: 13
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/24978983/Root/ph-3-127907437121075328
Trust level: Full
Application Virtual Path: /ph
Application Path: D:DB88ph
Machine name: 88DBWEB0

Process information:
Process ID: 1568
Process name: w3wp.exe
Account name: NT AUTHORITYNETWORK SERVICE

Exception information:
Exception type: SqlException
Exception message: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

Request information:
Request URL: http://88db.jobsdb.com/ph/Views/MediaUpload.aspx?PostID=50202&Type=I&panelid=postimagediv
Request path: /ph/Views/MediaUpload.aspx
User host address: 192.168.10.10
User: 50077
Is authenticated: True
Authentication Type: Forms
Thread account name: NT AUTHORITYNETWORK SERVICE

Thread information:
Thread ID: 15
Thread account name: NT AUTHORITYNETWORK SERVICE
Is impersonating: False
Stack trace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.WriteSni()
at System.Data.SqlClient.TdsParserStateObject.ExecuteFlush()
at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContext context, String id, Boolean getExclusive, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actionFlags)


Custom event details:

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.


View 10 Replies View Related

Error On DataReader Source

May 21, 2008



I have a problem with DataReaderSource.
I'm trying to get data from Notes table. I created a Connection manager
and the connection was successful. The SQLCommand in "Component properties"
tab is a simple "select * from <table_name>". When I switch to the
"Column mappings" tab, only the first column from the table is displayed.
Pressing the "Reftesh" button resulst in the following error:
Error at Data Flow Task {DTS.Pipeline]: The "output column <column_name> has a length that is not valid.
The length must be between 0 and 4000.
When I go to the "Input and Output Properties" tab, the DataType for the output column is not populated
and the error message "Error in Data Flow Task [DTS.Pipeline]: The output column <column_name> had an
invalid datatype (0) set."
The DataType property is not populated at all. Changing the data type to DT_STR results in error:
"Property value is not valid". Details: Error at Data Flow Task [DataReader Source]:
The data type of output columns on the component "DataReader Source" cannot be changed".



I read on a previous post to explicitly convert field , and tried to explicitly covnert the dataype on the field
in my query (ex. select convert(varchar(50) from fieldname)

It then gives foll err:


ERROR [42000] [Lotus][ODBC Lotus Notes]Incorect syntax near ','
[Lotus][ODBC Lotus Notes]Name, constant or expression expected.



Any idea on how to resolve this?

View 3 Replies View Related

Datareader Source Error

Oct 25, 2007

I get an error at the end of a 47 million row job when I use the datareader source. It goes through all the records and then the package fails. The error (DataReader Source [1]] Error: System.NullReferenceException: Object reference not set to an instance of an object. ) occurs at the datareader source. I suspect it's because my record set returns a null value at some point. Any ideas?

View 10 Replies View Related

Framework 2.0 Changes - TCP Provider, Error: 0 - An Existing Connection Was Forcibly Closed By The Remote Host.

Nov 14, 2005

If you connect to a server and open a query in SQL Managment studio (2005) and looses connection and then regain the connection, when you try to run the query it gives me a "TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host."   This happens against both 2005 and 2000 servers.   If I re-run the query it works.   However, this happens in our VB.NET app as well for clients with Wireless connections.   So, something has changed in Framework 2.0 regarding this, does anyone know how to tell the client to not throw this error and just try connecting the server instead which will work?  

View 105 Replies View Related

SSIS Error On DataReader Source

Feb 29, 2008

I have a package that runs every hour. It runs fine most of the time but once in a while

I get this not very helpful error message "the component 'xyz' is unable to process data" on DataReader Source component.

when i try to run it again on the same data it works fine. So i dont think it has to do with data.

Is there a way i can get more information on this error?

View 9 Replies View Related

Error: The Type Or Namespace Name 'DataReader' Could Not Be Found

Aug 1, 2006

In my DAL:using System;using System.Collections;using System.Data;using System.Data.SqlClient;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public DataReader getPersonList2() {        using (SqlConnection conn = getConnection())        {            SqlCommand cmd = new SqlCommand("PERSON_SP_getPersonList", conn);            cmd.CommandType = CommandType.StoredProcedure;            conn.Open();            return cmd.ExecuteReader();        }    }In my BLL:using System;using System.Collections;using System.Data;using System.Data.SqlClient;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;DAL d = new DAL();public DataReader getPersonList2(){        return d.getPersonList2();    }I get the following error in my BLL: Compiler Error Message: CS0246: The type or namespace name 'DataReader' could not be found (are you missing a using directive or an assembly reference?)
Source Error:





Line 34: }Line 35: Line 36: public DataReader getPersonList2(){Line 37: return d.getPersonList2();Line 38: }







Source File: c:InetpubwwwrootstudyApp_CodeBLL.cs
   Line: 36
Just wondering if someone could tell me why this is happening? I have the same namespaces that I have in the DAL in my BLL.Puzzled.

View 2 Replies View Related

Datareader Object Throws A Non-descript Error.

Mar 4, 2008

I call the datareader using a sqlCommand that I programmatically build and it accesses the database fine.  I can use the exact SQL command that I generate and I can get a result when i run it in SQL Management Studio.  When I run the application and try to access the datareader, it throws an exception whose message is quite frustratingly, <column name>, or in this case "image_URL".  Anyone have any idea what might be causing such an ambiguous error?

View 2 Replies View Related

SSIS Datareader ODBC Source Error

Feb 24, 2006

I am trying to import data from an ODBC source using the Datareader but have come accross a problem, can anyone help?

Whenever I try to do a 'SELECT * FROM sometable' I get the following error:

Error at Data Flow Task [DTS.Pipeline]: The output column "notes" (521) has a length that is not valid. The length must be betewwn 0 and 4000



Most of the tables we require have this field.

Is there any way to by pass this error and import the field as DT_WSTR type and convert to DT_NTEXT?

Our original DTS package (2000) worked well but we would like to move forward.



Thanks in advance.



John

View 1 Replies View Related

Error When Changing The Length On DataReader Source

Nov 3, 2006

Hi,
I am trying to import data from Oracle RDB into SQL Server 2005 using SSIS. Created a ODBC data source to connect to Oracle and used DataReader Source component and ADO.net to connect to the ODBC data source.

Under the Component properties tab, the SQL Command looks something like this.

Select ID, ADDRESS, REVISED from ADDRESS

The data type for the source columns are Integer, Varchar(30) and DATE VMS.

Now when I look at the Input and Output properties window,

The External columns has the following data types.

ID - four-byte signed integer [DT_I4]
ADDRESS - Unicode string [DT_WSTR], length = 0
REVISED - database timestamp [DT_DBTIMESTAMP]

The Output columns has the following data types

ID - four-byte signed integer [DT_I4]
ADDRESS - Unicode string [DT_WSTR], length = 0
REVISED - database timestamp [DT_DBTIMESTAMP]

When I tried to change the length of the ADDRESS on the output column, I get the following error.

Error at Data Flow Task [DataReader Source [1]]: The data type of output columns on the component "DataReader Source" (1) cannot be changed.

Error at Data Flow Task [DataReader Source [1]]: System.Runtime.InteropServices.COMException (0xC020837D)
at Microsoft.SqlServer.Dts.Pipeline.DataReaderSourceAdapter.SetOutputColumnDataTypeProperties(Int32 iOutputID, Int32 iOutputColumnID, DataType eDataType, Int32 iLength, Int32 iPrecision, Int32 iScale, Int32 iCodePage)
at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostSetOutputColumnDataTypeProperties(IDTSManagedComponentWrapper90 wrapper, Int32 iOutputID, Int32 iOutputColumnID, DataType eDataType, Int32 iLength, Int32 iPrecision, Int32 iScale, Int32 iCodePage)

Is this the default length for the Unicode string type. I was not able to load the ADDRESS column as it gets truncated before I load it into destination. Even if I use Derived or Data Conversion transformation, the ADDRESS is getting truncated before it reaches this transformation.

Any thoughts.

Thanks,
SK

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved