How To Drop A Queue Reader Agent ?

Sep 19, 2006

Hello,
by mistake I added an queue reader agent to a distribution database. But how can I drop the queue agent. There isn't a stored proc 'sp_dropqreader_agent'.
The only way I found (apart from dropping the whole distribution databse) is to stop and disable the generated job!

Is there any other way to get rid of the queue reader agent ?

Wolfgang

View 7 Replies


ADVERTISEMENT

Queue Reader Agent Fails To Start When Stopped Through Enterprise Menager

Feb 9, 2005

I've set up transactional replication with queued updating. If I stop the queue reader agent through EM, I can't start it again. Agent's history says "Queue Reader aborting. The step failed."

All servers are SQL Server 2000 SP3.

Help is greatly appreciated!

View 1 Replies View Related

Queue Reader Agents Failed - SQL 200 Replication

Jan 19, 2006

Guys,

I get the error message: Queue reader aborting. The steps failed...in queue reader agents of SQL 2000 replication. Could any one give me a hint of how to troubleshoot this problem? Thanks a lot in advance.

View 1 Replies View Related

Service Broker Queue Reader Question

Aug 31, 2006

I'm creating an app that could potentially send thousands of messages to a Service Broker queue in a matter of seconds. The stored proc that reads records off the queue will call a remote stored procedure for each message to save data in a remote database.

My question is this. How does Service Broker determine how quickly to read those messages off the queue it was sent to? Ideally I'd like Service Broker to do most of its work when SQL Server isn't busy doing other things instead of contending with SQL Server while it's doing perhaps more important work. Is there any way to control this? How does this work?

Thanks very much - Amos

View 3 Replies View Related

Updatable Transactional Replication, Queue Reader Error

Jul 3, 2007

I have just started getting the following error from the queue reader but I can't see why.



The Queue Reader Agent has encountered the error ''Row handle is invalid.'' when connecting to ''Database'' on ''ServerName''. Ensure that the publication and subscription are defined properly and that both servers are running.



Does anybody know what it means / how I can fix the problem?



Thanks

View 11 Replies View Related

Snapshot Agent && Log Reader Agent Will Not Start.

Nov 30, 2006

Hi All,

I would appreciate any help here at all. I am pulling my hair out!

I am unable to start the snapshot agent or log reader agent from within SQL management studio. it fails on executing step 2 with unknown username or bad password.

I have checked all account details and they are correctly using my domain admin account. I can connect to SQL using teh same account and it also has sysadmin permissions.

If i copy the step 2 paramters and start from the cmd prompt (again logged in using the same domain account) they both start fine.



Any ideas would be gratefully received.

View 1 Replies View Related

Cannot Start Log Reader Agent And Snapshot Agent

May 18, 2007

I am testing peer to peer replication in our environment. I simulated a three node peer to peer topology and a local distributor.

For some wierd reason I cannot get the Log Reader Agent and snapshot agent to start. The domain account under which SQL Server Agent runs has administrator previlage on the box. I also use a domain account for SQL Server Service. (none of the passwords changed).

This is the error I am getting - "Executed as user: abc. A required privilege is not held by the client. The step failed"

Any ideas???





Also this domain account is a member of



SQLServer2005MSSQLUsers$ServerName$MSSQLSERVER

SQLServer2005MSAgentUser$ServerName$MSSQLSERVER


View 3 Replies View Related

Log Reader Agent Won't Start

Jun 22, 2004

We restored a database with replicated tables. Now, the Log Reader Agent will not run. This displays:
"The process could not execute 'sp_repldone/sp_replcounters' on 'ourservername'."
In Error Details for the agent:
"The process could not set the last distributed transaction."
And, from the logs:
"ForwardLogBlockReadAheadAsync: Operating system error 998(Invalid access to memory location.) encountered."

Does anyone know how we get the Distribution database and the Log Reader running again?
It is only affecting Transactional replication (not snapshot or merge).

View 4 Replies View Related

Log Reader Agent Failure

Feb 15, 2006

HELP>>> I am getting desperate
we recently had a failure which ended up wrecking my replication. The basic layout is from a source server -> Distribution Server then out to several other servers. Long story short the distribution database had to be moved to a new drive and I am now getting the following error message

The specified LSN (0003d4f0:0000721e:001b) for repldone log scan occurs before the current start of replication in the log (0003d63a:00002803:0001).
(Source: fsdpdcis (Data source); Error number: 18768)
---------------------------------------------------------------------------------------------------------------
The process could not set the last distributed transaction.
(Source: fsdpdcis-DPDDATA-1 (Agent); Error number: 22017)

I have reinitialized all subscriptions on the fsdpdcis server and run subscription validation (with no response). The data did re-load during the reinitialization but does not seem to be getting updated. This is driving me crazy and I am desperate. Any suggestions would be greatly appreciated. I have search MS knowledge base with no results and BOL has not been any help so far.

Thanks
Steve

View 4 Replies View Related

Log Reader Agent -transactional Replication

Aug 2, 2001

Unable to start log reader agent after being manually stopped.

Any ideas.

View 1 Replies View Related

Log Reader Agent Access Violation

Apr 7, 2006

I recently set up transactional replication from one server database to another server database. I keep getting a Log Reader Agent error: An access violation occurred.

The SQL Server agent starts under one Windows account but the Server is registered under the system account. The log reader agent is using the system account.

I'm not sure what else to check or what database permissions or roles should be set. Can somebody help? Thanks.

View 5 Replies View Related

Run Status Of Log-reader-agent Job Is Displayed Incorrectly

Jun 12, 2002

hi,

among our server-agent jobs is one for the log-reader-agent and its run status is displayed as error though the log-reader is working correctly, replication is working fine.
it had hit an error some days ago after an unexpected shutdown - but it has been auto-restarted correctly on restart of the sql-server agent.
now - what can i do to get back to a sensible run-status report?
i have already deleted the job-history with the hope that this might help - but it didn't. should i just stop and restart the job again?
can i somehow delete the status in the jobhistory?
i would gladly appreciate any ideas because it's making me just mad to have a 'failed' job status on the monitor *g*

thank you,
kerstin

View 1 Replies View Related

Sql 2000 Replication And Stopping Log Reader Agent

May 10, 2006

Question:
I am unclear what syntat to use to stop (suspend) the log reader agent.

Things I Understand:
I understand how to manually stop the reader agent using the enterprise manager.

I understand how to schedule the load reader frequency (properties of the agent)

My Intention:
to stop the log reader agent, execute another scheduled job, then restart the log reader

Any suggestions are appreciated: comment here or send to:fglomb@crtincbc.com

Thanks!

View 1 Replies View Related

Log Reader Agent Lacks A Required Privilege

May 12, 2006

I'm using our development ID to set up peer-to-peer replication. I am following the steps outlined in the BOL using SQL Studio 2005. When I created the initial publication, I read the section on permissions and assigned the development login ID db_owner. Indeed, to eliminate any possible issues (I thought), I gave it db_datareader, db_datawriter, and all the db admin rights and made very sure the db_denydatareader and db_denydatawriter roles were not checked. I did this through the Logins section of the Security folder and applied the same rights to both the distribution and the publication database. Nevertheless, when I run the LogReader agent job, it fails with the message for step 2 that:

Executed as user: ourdomsqldev. A required privilege is not held by the client. The step failed.

The dev ID essentially has sa rights to the server and all the databases. It is also a domain authenticated ID. Any ideas what's causing this problem? I really need to get the replication going reliably before the weekend is out.

Thanks.

Randy

View 1 Replies View Related

SQL Server Agent Doesn't Act As Batch Queue Login

Apr 2, 2007

[I originally posted this in the General Tools forum, but perhaps I'll get better response here...]



I am wondering if this is a bug or a (strange) feature: when a SQL Server Agent job step is a CmdExec job (properly configured for owner/proxy, etc), the step is invoked with the proper user credentials (of the 'Run As' account); HOWEVER, the job step doesn't ever seem to be logged in and thus the step does not pick up the critical local group membership(s) such as BATCH (my preference) or SERVICE, etc. Provided that the command consists solely of built-ins or specifically-permissioned executable invocations (permissioned to the specific 'Run as' account), all is well. However, if the command attempts to invoke general OS exe's (cmd.exe as a sub-shell, whoami, ftp, etc -- anything that is generally permissioned via a local group such as BATCH or SERVICE), such invocations fail with access denied. Specifying a CmdExec step with 'whoami /all' as the command demonstrates the missing group memberships.

(The only workaround seems to be to either crawl through the OS exes and assign permissions, or to grant administrator membership to the proxy credentials account.)

So, design feature or major annoyance?



[Additional info I left out: SS05 (same behavior on SP2 and SP1); on WS03R2-x64; in an Active Directory domain; 'Run as' account granted log on as service, log on as batch, etc.]



Thanks,

-frank

View 1 Replies View Related

SqlDataReader Reader Connection Closing Before Dt.Load(reader)

Jun 26, 2007

As you see in the images the connection is closing. During the read it counts 5 columns which is correct. When I step through the code it closes the connection when it hits dt.Load(reader) and nothing is loaded into the datatable.
 
------------------------------------------------------------AS I STEP THROUGH -----------------------------------------------------------------------------------------------------------------------

 
Please help,
 
Thanks,
Tom

View 1 Replies View Related

Clarifications On Queue Service And Queue Readers

Jan 11, 2006

Hello,
This is info that I am still not certain about and I just need to make sure, my gut feeling is correct:

A.
When a procedure is triggered upon reception of a message in a queue, what happens when the procedure fails and rolls back?
1. Message is left on the Queue.
2. is the worker procedure triggered again for the same message by the queue?
3. I am hoping the Queue keeps on triggering workers until it is empty.

My scenario is that my queue reader procedure only reads one message at a time, thus I do not loop to receive many messages.

B.
For my scenario messages are independent and ordering does not matter.
Thus I want to ensure my Queue reader procedures execute simultaneously. Is reading the Top message in one reader somehow blocking the queue for any other reader procedures? I.e. if I have BEGIN TRANSACTION when reading messages of the Queue, is that effectively going prevent many reader procedures working simultaneously. Again, I want to ensure that Service broker is effectively spawning procedures that work simultaneously.

Thank you very much for the time,

Lubomir

View 5 Replies View Related

Drop All Indexes In A Table, How To Drop All For User Tables In Database

Oct 9, 2006

Hi,I found this SQL in the news group to drop indexs in a table. I need ascript that will drop all indexes in all user tables of a givendatabase:DECLARE @indexName NVARCHAR(128)DECLARE @dropIndexSql NVARCHAR(4000)DECLARE tableIndexes CURSOR FORSELECT name FROM sysindexesWHERE id = OBJECT_ID(N'F_BI_Registration_Tracking_Summary')AND indid 0AND indid < 255AND INDEXPROPERTY(id, name, 'IsStatistics') = 0OPEN tableIndexesFETCH NEXT FROM tableIndexes INTO @indexNameWHILE @@fetch_status = 0BEGINSET @dropIndexSql = N' DROP INDEXF_BI_Registration_Tracking_Summary.' + @indexNameEXEC sp_executesql @dropIndexSqlFETCH NEXT FROM tableIndexes INTO @indexNameENDCLOSE tableIndexesDEALLOCATE tableIndexesTIARob

View 2 Replies View Related

Execute Sql Server Agent Job Task - Job Immediately Returns Success... However Agent Job Is Still Running???

Nov 30, 2006

when I run a package from a command window using dtexec, the job immediately says success.
DTExec: The package execution returned DTSER_SUCCESS (0).
Started: 3:37:41 PM
Finished: 3:37:43 PM
Elapsed: 2.719 seconds



However the Job is still in th agent and the status is executing. The implications of this are not good. Is this how the sql server agent job task is supposed to work by design.



Thanks,

Larry

View 1 Replies View Related

Log Reader

Aug 22, 2007

We dont want to use triggers or replication to capture changes in a set of tables; we have the same problem in Oracle and we use LogMiner to do so. We have been looking for similar tools in SQL Server but the ones we have found so far dont seem to fulfill our requirements (Redgate and Lumigent).
Does anyone know any other third party application that can read a SQL Server log and extract changes filtering by table name?

Thanks.

View 1 Replies View Related

SQL Server Agent Could Not Access Replication Agent

Feb 19, 2007

We just moved source server to newer, bigger box ... Windows 2003 and Active Directory ... Snapshot agent worked but distribution failed ... Same login as on older machine, login is sysadm, used DCOMCNFG to allow ability to launch process ... What are we missing?

View 4 Replies View Related

Data Reader ?

Sep 24, 2007

is it possible to use a data reader to read from 2 tables with 1 store procedure(sp)?
 -------------------------------------------------
ex:
create sp1
as 

select * from tbl1
select * from tbl2
 -------------------------------------------------
 how can i use a data reader to read the items from tbl2?
 

 
 

View 5 Replies View Related

Data Reader

Feb 22, 2008

Hi Guys,I have a quick question about DataReader, I have a function called "ExportTotal" i am calling this function from another function. what it does is it will put the Total for each Network in the Line 34. Right now what it is doing is It is putting the First Networktotal,2ndNetwork total,3rdNetwork total....... in the line 34. what i want is if the control comes to first network then it has to put only 1st network total and for the 2nd network only 2nd network total and so on. Please see my function below. Can you guys tell me what i am doing wrong?ThxPrivate Function exporttotal() As String Dim sql As String Dim dbFunctions As New DatabaseUtilities Dim tempinvoicetotal As String 'Dim rateactuals As String Dim filetext As String Dim tempclientname As String Dim strconn As String Dim prev_network As String = "" Dim current_network As String = "" strconn = CONNECTIONSTRING sql = "SELECT CAST(SUM(tblSpot.rateActual) AS int(4)) AS Rateactuals, SUM(tblSpot.rateActual * 0.85) AS netrate, SUM(tblSpot.rateActual * 0.15) AS commrate,TBLCLIENT.CLIENTNAME " & _"FROM tblSpot INNER JOIN tblContract ON tblSpot.fkContract = tblContract.pkid INNER JOIN " & _ " tblClient ON tblContract.fkClient = tblClient.pkid WHERE tblSpot.fkContractType = 'UNWIRED' AND " & _ "fkInvoiceNumber = '" & Me.txtinvoicenumber.Text & "' GROUP BY TBLCLIENT.CLIENTNAME" Dim myConn As New SqlConnection(CONNECTIONSTRING) Dim myCommand As New SqlCommand(sql, myConn) myConn.Open() Dim dbreader As SqlDataReader = myCommand.ExecuteReader() While dbreader.Read() Try Dim Rateactuals As String If dbreader("Rateactuals") Is DBNull.Value Then Rateactuals = "" Else Rateactuals = dbreader("Rateactuals") tempinvoicetotal = Rateactuals End If Dim clientname As String If dbreader("clientname") Is DBNull.Value Then clientname = "" Else clientname = dbreader("clientname") tempclientname = clientname End If If prev_network = "" Then filetext = filetext & vbCr & "34;;" & tempinvoicetotal & "00" & ";"Session("EDIExport4") = filetext prev_network = tempclientname Else current_network = tempclientname If prev_network <> current_network Then filetext = filetext & vbCr & "34;;" & tempinvoicetotal & "00" & ";"Session("EDIExport4") = filetext prev_network = tempclientname Else End If End If Catch SqlEx As SqlClient.SqlException Session("Error") = SqlEx.Message.ToString Response.Redirect("Error.aspx?Form=" & Request.Path) Catch Ex As System.Exception Session("Error") = Ex.Message.ToString Response.Redirect("Error.aspx?Form=" & Request.Path) End Try dbFunctions = Nothing End While myConn.Close() End Function

View 7 Replies View Related

ADO.net (how To Close A Reader)

Nov 29, 2005

Hello, I'm trying to run the following snippet as Console app, and I get an error: "a reader is already open for this connection, and should be closed first" I tried to manually say: SqlDataReader.Close() in the begining of the code, but still get the error, Any suggecstions how to manually close the reader? thank you ---------- here's the code -----------using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; namespace ADO.NET { /// <summary> /// Summary description for Class1. /// </summary> class Class1 { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { SqlConnection cn = new SqlConnection ("SERVER=MyServer; INTEGRATED SECURITY=TRUE;" + "DATABASE=AdventureWorks"); SqlCommand cmd1 = new SqlCommand ("Select * from HumanResources.Department", cn); cmd1.CommandType = CommandType.Text; try { cn.Open(); SqlDataReader rdr = cmd1.ExecuteReader(); while (rdr.Read()) { if (rdr["Name"].ToString() == "Production") { SqlCommand cmd2 = new SqlCommand("SELECT * FROM " + "HumanResources.Employee WHERE DepartmentID = 7", cn); cmd2.CommandType = CommandType.Text; SqlDataReader rdr2 = cmd2.ExecuteReader(); while (rdr2.Read()) { } rdr2.Close(); } } rdr.Close(); } catch (Exception ex) { Console.WriteLine (ex.Message); } finally { cn.Close(); } } } }

View 2 Replies View Related

Problems With More Than 1 Reader

Mar 13, 2006

Dim conn As SqlConnection = Nothing
Dim cmd As SqlCommand
Dim cmd2 As SqlCommand
try
conn = New SqlConnection(ConfigurationManager.ConnectionStrings("myConnection").ConnectionString)
conn.Open()
cmd = New SqlCommand
cmd.Connection = conn

cmd2 = New SqlCommand
cmd2.Connection = conn
dim reader As SqlDataReader = cmd.ExecuteReader
Right this works and I can access reader fine
but as soon as I do the following I get an error
reader2 = cmd2.ExecuteReader (reader2 is already declared just not put on here)
the error is "There is already an open DataReader associated with this Command which must be closed first."
which is odd because there sqlcommand used for reader2 is different.
Can I not use more than one reader at anyone time? I used to have loads of recordsets open in asp 3 no prob.
Cheers

View 3 Replies View Related

Datasource Reader

Apr 28, 2008

I am trying to do incremental extract using Datasource reader.
I need to send a variable in where condition to extract the data base on the max date from other table.


To implement this i have created two variables
1)to get the max date from the table.
2)to store the sql query and send the mad date from other variable to extract the data.

i have give this sql variable in data flow expression.but its not working.

can any one tell me where i am going wrong.

View 2 Replies View Related

Log Reader Internal

Apr 26, 2007

MY Current database in SIMPLE recoverey model



I have set up the transactional replication. MY log reader process wakes up and runs every 5 min. Does my transactions will get deleted or they still in log file as active even it is in simple recover model.



Logreader how it reads the Transaction log files .? I observed today we are running some big reports. those reports uses INSERT INTO FROM <TABLE > this process showing in DBCC OPENTRAN

MY log reader keep on reading the log file.. it did not come out from that five min duration...



Can someone from the MS share the what /how exactly log reader works ( inside details)

I would like to add more details



The Log Reader Agent is scanning the transaction log for commands to be replicated. Approximately 30500000 log records have been scanned in pass # 3, 1696 of which were marked for replication, elapsed time -623164036 (ms).

The Log Reader Agent is scanning the transaction log for commands to be replicated. Approximately 31000000 log records have been scanned in pass # 3, 1713 of which were marked for replication, elapsed time -177869239 (ms).

everytiome counter startwith 500000 records and keegoing for some time and it is delivering the transactions never stopping the job

Why elpse time is in negative?



How to understan

Do you guys think it is really sc



Thanks

Srini

View 25 Replies View Related

Sqldata Reader Question

Jul 18, 2006

Hi,
I am trying to creating an application using C# where I read data from a SQL server. In the database, I have two tables. One that has the Order info and other table has the item info for each of the rows in the Order table. In my application I am run a query and open up a datareader to read in the Order info. While OrderInfoDataReader is still open, I run another query to get the ItemInfo and open another data reader. Well, ADO.Net does not allow two datareader be open at the same time.
My question, what would be a way around to solve the issue? I would greatly appreciate your help.
Thanks,
Emon.

View 1 Replies View Related

Help Retreving Value Form Sql Reader

Aug 18, 2006

hello,
 
I have tried myReader.GetSqlString, GetSqlValue, GetSqlInt16, etc...etc...
But I keep getting an error (System.InvalidCastException was caught  Message="Conversion from type 'SqlInt32' to type 'String' is not valid."  Source="Microsoft.VisualBasic"  StackTrace:       at Microsoft.VisualBasic.CompilerServices.Conversions.ToString(Object Value)       at ImportDelimitedFile.SumCurrentAmount() in C:Documents and Settingsemg3703My DocumentsVisual Studio 2005EscuelasComunidadImportDelimitedFile.aspx.vb:line 556)
 
Here is my code:
 Public Function SumCurrentAmount() As String        Dim sqlconn As New SqlConnection(ConfigurationManager.ConnectionStrings("GDBRemitanceConnectionString1").ConnectionString)        Dim sqlcmd As New SqlCommand("SELECT SUM(CONVERT (Int, Field_6)) AS TotalAmount, Record_Type FROM tblTempWorkingStorage_NACHA GROUP BY Record_Type HAVING (Record_Type = '6')", sqlconn)        Try            sqlcmd.Connection.Open()            Dim myReader As SqlDataReader            myReader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection)            If myReader.Read() Then                SumCurrentAmount = CType(myReader.GetSqlValue(0), String)                Return SumCurrentAmount            Else            End If            myReader.Close()        Catch        End Try        sqlcmd.Connection.Close()    End Function
 
I need to know which "GetSql...(type) should I used to extract field numbre one from myReader.
 
Thanks a lot,

View 1 Replies View Related

Data Reader Problem

Jun 11, 2007

Hi All,
   I got an error while running this code.There is already an open DataReader associated with this Command which must be closed first
  How can I resolve the error?
 
protected void Page_Load(object sender, EventArgs e)    {        string sql;                SqlConnection Connection = new SqlConnection("ConnectionString");        sql = "SELECT PO_SE_Line_ID  FROM  PO_STOCK_QUERY_LINE_DETAILS WHERE TRANS_NUM ='TR-A-00-01-93'";
        SqlCommand command = new SqlCommand(sql, Connection);        SqlDataReader Dr;        Connection.Open();        Dr = command.ExecuteReader();                                while (Dr.Read())                {
 sql = "SELECT SUPPLIER_ITEM_CODE,SUPPLIER_MAN_DESC,SUPPLIER_PAT_DESC,SUPPLIER_ITEM_DESC,SUPPLIER_ADDIT_DESC,SUPPLIER_SUGG_RETAIL FROM PO_STOCK_QUERY_LINE_DETAILS where TRANS_NUM ='TR-A-00-01-93' and PO_SE_Line_ID=" + Dr["PO_SE_Line_ID"].ToString();
               SqlCommand command1 = new SqlCommand(sql, Connection);
               SqlDataReader Dr1;
                   
                    Dr1 = command1.ExecuteReader();                                        while(Dr1.Read())                    {
 
                    Response.Write(Dr["SUPPLIER_ITEM_CODE"].ToString());                    Response.Write("<br>");                    Response.Write(Dr["SUPPLIER_MAN_DESC"].ToString());                    Response.Write("<br>");                    Response.Write(Dr["SUPPLIER_PAT_DESC"].ToString());                    Response.Write("<br>");                    Response.Write(Dr["SUPPLIER_ITEM_DESC"].ToString());                    Response.Write("<br>");                    Response.Write(Dr["SUPPLIER_ADDIT_DESC"].ToString());
      }Dr1.Close();
     }Dr.Close();
 
I tried to close the first data reader before opening the second data reader.still the error persists.

View 5 Replies View Related

Data Reader Problem

Jun 26, 2007

Hi, i dont know whats gone wrong! but all of a sudden it seems to be throwing an error, i have looked at my previous code and it matches exactly when it was working, here is the code below int i = 0;for (i = 1; i <= 3; i++)
{
 
//This gets the stock ID from the textbox.string stock_ID = ((TextBox)Panel1.FindControl("txtID" + i.ToString())).Text;
 
//This is the sql statement.string sql = "SELECT [n_or_sh], [title], [cost_price], [selling_price] FROM tbl_stock WHERE stock_ID = " + stock_ID;
 
//This creates a sql command which executes the sql statement.SqlCommand sqlCmd = new SqlCommand(sql, myConn);
myConn.Open();
//This is a reader for the results to go in.SqlDataReader dr = sqlCmd.ExecuteReader();
//This reads the first result from the sqlReader
dr.Read();
//This sets the title label text to the value of the description column.TextBox currentBox1 = (TextBox)Panel1.FindControl("txtDesc" + i);
string strtxtDesc = currentBox1.Text;strtxtDesc = dr["title"].ToString();
 
 
};
myConn.Close();
i = 0;
 
the error its throwing is this
CS1519: Invalid token '(' in class, struct, or interface member declaration for the line myConn.Open()
does anybody have any idea how to solve this?
Jez

View 4 Replies View Related

Coexisting SQL Reader && UPDATE

Aug 17, 2007

In my current application, I have an administration form that fills in labels and checked states via data entered into the database using a similar user input field. What the admin page does is it first lists all the record names in a listview, then on select, it fills in the form based on what the records contain. This means labels text change, and check states change based on the string "True" or "False". This was done using the SQL Reader command.
 Within the same form, the read checkboxes are editable via the admin. When the admin edits the controls, he will click the update button at the bottom and the database will UPDATE .. WHERE UserName = (Scalar for ListBox1.SelectedValue)
I've used the exact same UPDATE command in my form for the user, except the only difference was @ the WHERE clause-- I had it updating based on a GUID. I know my SQL statement is correct, but it just won't update the data.
Is it possible that the READER, which starts (and closes) on pageload cannot coexist within the same form as the UPDATE code?
My code is incredibly long, so for the purposes of a short post I'm not including any bit of it-- but if you would like to see it, just let me know.

View 5 Replies View Related

Sqldatareader Within A Loop From Another Reader?

Dec 26, 2007

I have an SqlDataReader which loops through records returned from an SP, within that loop I would like to initiate another SP, but for some darn reason the following code won't work: // create SqlConnection object
string ConnectionString = ConfigurationManager.ConnectionStrings["aiv3cs"].ConnectionString;
SqlConnection myConnection = new SqlConnection(ConnectionString);

try
{
// Create a new XmlTextWriter instance
XmlTextWriter writer = new
XmlTextWriter(Server.MapPath("products.sitemap"), Encoding.UTF8);

writer.WriteStartDocument();
writer.WriteStartElement("siteMap");
writer.WriteAttributeString("xmlns", "http://schemas.microsoft.com/AspNet/siteMap-File-1.0");

// create the command
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection;

// set up the command
myCommand.CommandText = "spGetMenuStructure";
myCommand.CommandType = CommandType.StoredProcedure;

// open the connection
myConnection.Open();

// run query
SqlDataReader myReader = myCommand.ExecuteReader();

bool HasSubElements = false;

SqlCommand myCommand2 = new SqlCommand();
SqlParameter myParameter1 = new SqlParameter();
SqlDataReader myReader2 = new SqlDataReader();

// parse the results
while (myReader.Read())
{
// create the command
myCommand2.Connection = myConnection;

// set up the command
myCommand2.CommandText = "spGetMenuSubElements";
myCommand2.CommandType = CommandType.StoredProcedure;

myParameter1.ParameterName = "@ContentID";
myParameter1.SqlDbType = SqlDbType.Int;
myParameter1.Value = Convert.ToString(myReader["ID"]);

myCommand2.Parameters.Add(myParameter1);

// run query
myReader2 = myCommand2.ExecuteReader();

while (myReader2.Read())
{
HasSubElements = true;
}

myReader2.Close();

if (Convert.ToString(myReader["HasPage"]) == "1")
{
writer.WriteStartElement("siteMapNode");
writer.WriteAttributeString("title", Convert.ToString(myReader["PageTitle"]));
writer.WriteAttributeString("description", Convert.ToString(myReader["PageTitle"]));

string PageURL = Convert.ToString(myReader["PageName"]) + "?ContentID=" + Convert.ToString(myReader["ID"]);

writer.WriteAttributeString("url", PageURL);

if (HasSubElements)
{
writer.WriteEndElement();
}
}
else
{
writer.WriteStartElement("siteMapNode");
writer.WriteAttributeString("title", Convert.ToString(myReader["PageTitle"]));
writer.WriteAttributeString("description", Convert.ToString(myReader["PageTitle"]));
}

HasSubElements = false;
}

myReader.Close();

// end the xml document and close
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
}

finally
{
myConnection.Close();
}I've gotten the following two errors:There is already an open DataReader associated with this Command which must be closed first.And a build error:Error29The type 'System.Data.SqlClient.SqlDataReader' has no constructors defined Any suggestions would be most appreciated.    

View 4 Replies View Related







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