Hi, everyone, I am new in SQL server 2005. I had setup SQL server 2005 P2P replication. Somehow it did not work one of two way replication. I tried to delete the publication. However I could not do it. have the same problem. When I tried to delete the publication, I got the publication " " does not exist.[SQL server error: 20026]. I tried to use sp_droppublication, it gave me error "the database is not enabled for publication". Nevertheless, I can see the publication in MS SQL Management Studio and Publication monitor with OK status. I could not find the distribution database either.
Could you anyone has ideas to delete this publication? I am sorry I am not a programmer. Please give me more detail explanation if you can. Thanks.
I've Installed VS2005 and MSSQL express with it. I used to work with mssql 2003 enterprise edition where it had "Enterprise Manager" from which I could create and modify my Databases.
How do I creat a new database with MSSQL express?
I've tried to do this via visual studio 2005 "server explorer". I"m entering the "Create new SQL Server Database" dialog, I select my server's name and my new database name and I recive an error message which says "An error has occurred while estabilishing a connection to the server" and it also says that
"When connecting to SQL server 2005, this failure may be caused by the fact that under the defult settings SQL sever does not allow remote connections".
How do configure my MSSQL express to allow the remote connection?
I have a DataBase name Customer Customer have 30 Tables name table1 �table2�table 3... I want to have a DataBase name Customer_Offile with same Table same column like Customer ( the Customer_Offlike will used to a backup DataBase) How to wirte a script for copy Customer? thank you very much
We're new to SQL Reporting Services and have a new SQL 2005 server.
I'm having a problem activating scubscriptions.
- "New Subscription" is greyed out in Server Management Studio.
- Subscribing via the browser, even as the Content Manager, allows you to fill in the form for the subscription but then reports the following error;
"The current action cannot be completed because the user data source credentials that are required to execute this report are not stored in the report server database. (rsInvalidDataSourceCredentialSetting)"
Any suggestions?
Found the problem.
When configuring the Data Source the "Impersonate the authenticated user after a connection has been made to the data source" button should be off.
Hello This code was translated from c# but I keep getting this error. The variable name '@UserId' has already been declared. Variable names must be unique within a query batch or stored procedure Any ideas I have tried changing the user id name but no luck. thanks
Partial Class userInherits System.Web.UI.Page Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser Dim UserNameTextBox As TextBox UserNameTextBox = CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName")Dim DataSource As SqlDataSource = CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo") Dim user As MembershipUser = Membership.GetUser(UserNameTextBox.Text)Dim UserGUID As Object = user.ProviderUserKeyDataSource.InsertParameters.Add("UserId", UserGUID.ToString()) DataSource.Insert() End Sub End Class
select episode_key as episode_key, ee.object_key, ee.encounter_begin_dt , cp.procedure from dbo.encounters e
join (
select episode_key as minepisode, min(isnull(e.object_key,e.Object_key_History) ) as object_key, min(e.encounter_begin_dt)as encounter_begin_dt
from dbo.encounters e
join dbo.CD_Procedure CP on CP.Procedure_CD = e.procedure_cd where cp.procedure > 0
group by e.episode_key
)ee on e.object_key = ee.object_key
join dbo.cd_procedure cp on cp.procedure_cd = e.procedure_cd
CREATE UNIQUE CLUSTERED INDEX IDX_V1
ON vwLookAdmissionRecord (episode_key)
but i keep getting an error:
annot create index on view "dbo.vwLookAdmissionRecord" because it references derived table "ee" (defined by SELECT statement in FROM clause). Consider removing the reference to the derived table or not indexing the view.
I am new to ASP.NET and met a problem about access a database on a Web Server (www.myserver.com). My meaning here that I created a .sql from my localhost to test, but when to upload to my web server on the internet, an error occured: "System.Data.SqlClient.SqlException: SQL Server does not exist or access denied". Anyone here can help me to solve my problem. Waiting for your reply soon. Thanks
Hi, I already got a database and I need to add another stored procedure on it in order to call it from the SSIS package. But when I execute the sql file to create the procedure, there is a error message popping out like:
"Cannot add rows to sys.sql_dependencies for the stored procedure because it depends on the missing table 'logit'. The stored procedure will still be created; however, it cannot be successfully executed until the table exists."
And I have tried it on another computer, there is the same error. Could you please tell me how to solve the problem. Thanks very very much.
I am hosting my website with a web hosting company on the web. My web application readsdata from a SQL server 2005 database. So far I have been able to establish a connection to the database, but when I attempt to query data from a table, I a get an error message.I can't figure out what I am doing wrong here.basically I just want to read data from acolumn in the database and to store it into a multi-line textbox control. I am using someinline sql for the call. Can someone help me out here? public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { mySqlConnection = new SqlConnection(ConnectionStringConst); mySqlConnection.Open(); try { // Database is named "Torsion", Table I am querying is named "Content" SqlCommand cmd = new SqlCommand("SELECT * FROM [Torsion].[dbo].[Content] ORDER BY [Section] DESC", mySqlConnection); rdr = cmd.ExecuteReader(); ListBox1.DataSource = rdr[0]; ListBox1.DataTextField = "HLContent"; // HLContent is the first column in my database ListBox1.DataBind(); // I want to store HLContent into ListBox1 control } catch { throw;} finally { mySqlConnection.Close(); mySqlConnection.Dispose(); } }}-----------------------------------------ERROR_MESSAGE_BELOW---------------------------- Server Error in '/' Application.
Invalid attempt to read when no data is present. 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: Invalid attempt to read when no data is present.Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
[InvalidOperationException: Invalid attempt to read when no data is present.] System.Data.SqlClient.SqlDataReader.GetValue(Int32 i) +137 System.Data.SqlClient.SqlDataReader.get_Item(Int32 i) +7 _Default.Button1_Click(Object sender, EventArgs e) +167 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832
I have a standard Login ASP.NET 2.0 control on a login Page, a LoginName and LoginStatus controls on the member's page. once the user login successfully I am redirecting the user to Member.aspx page. The following is my machine configuration
Windows XP Pro Service Pack2 IIS 5.1 SQL Server 2000 visual Studio 2005 DISABLE ANONMYOUS ACCESS IN IIS ENABLE WINDOWS AUTHENTICATION
I am Using form authentication, and I am getting following error "Your login attempt was not successful. Please try again".
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> You are back ........ <asp:LoginName ID="LoginName1" runat="server" /> <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="Redirect" LogoutPageUrl="~/Login.aspx" />
</div> </form> </body> </html>
Member.aspx.cs
using System; using System.Data; using System.Configuration; using System.Collections; 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 partial class Member : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.Write("<br/>Page.User.Identity.Name: " + Page.User.Identity.Name); Response.Write("<br/>Page.User.Identity.IsAuthenticated: " + Page.User.Identity.IsAuthenticated); Response.Write("<br/>Page.User.Identity.AuthenticationType: " + Page.User.Identity.AuthenticationType);
I have a C# application that connects to a SQL Server Express 2005 instance. One of the testers here shuts his machine down every night and first thing in the morning when he fires up the application it fails to connect. If he tries to open it again right after that it connects. What would the failed attempt do that would fix the instance?
This is my 1st attempt at designing a database, and I have not finished it completely, but I would like somebody to review and critique for me. I really don't want to make any mistakes with this and I would appreciate any expertise out there to direct, recommend, suggest improvements and/or changes, PLEASE.
Thank you for considering this,,,if you provide me with your e-mail, I can send you a script.
I have a Local DTS Package which will execute fine...no problems. When I try to schedule it from my NT 4.0 Workstation to the NT 4.0 Server, I get the job scheduling dialog box...fill it out...click OK...and NOTHING.
No error message, nothing in the SQL error log, nothing in the NT logs, no job in the schedule! When I perform the same task at the server logged in as Administrator it schedules successfully.
Hi all, I'm not too sure if this should be in this forum or in the admin one, but since DBCC is required to fix this error, so I might as well put it here. What I'm having is this error msg:
Attempt to fetch logical page in database 'DBName' belongs to object 'TableName', not to object 'TableName'. Error: 605, Severity: 21, Stat: 1
I've checked BOL and it said that DBCC CheckTable on the 2nd table will fix this issue (or by using CheckDB), that is fine but what I want to know is why is this happening, and how to prevent it, I have a cluster server holding this DB, we have disabled write cache and we have tried to fail over to another node, but this issue does happen again (more often now), its running on SQL 2000 with sp4. Anyone got any ideas of why this is happening? and how to prevent it? Thanks
hi i want to creat server using sql server 2005 and connect the server with clients (computers) my question is : 1-must be the server computer using OS Windows Server 2-which book you advice me to read for creat server using SQL Server 2005 database thank you
I was hoping I could get this to work, so far I can access all the data from the database, but I also want to update it. I placed a button, updateBttn_Click event to update the database.It's not updating though and I am not gettting any errors. Could you please look at the update query in the update button and see if I have it right. Also, I think it might be because I have the first retrieval of the database tables set to ExecuteReader(). Do I need to redo this and use ExecuteNonQuery somewhere else?Thanks in advance. using System;using System.Data;using System.Configuration;using System.Collections;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.Data.SqlClient;public partial class userpage : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { usrnmeLbl.Text = PreviousPage.CurrentUser; hiddenpassLbl.Text = PreviousPage.CurrentPass; //Define database connection SqlConnection conn = new SqlConnection( "Server=localhost\SqlExpress;Database=MyDB;" + "Integrated Security=True"); //Create command //SqlCommand comm = new SqlCommand("SELECT UserName, Password, UserID FROM UsersTable WHERE UserName = '" + usrnmeLbl.Text + "'", conn); //SqlCommand comm = new SqlCommand("SELECT Father FROM FamHistTable WHERE UserID IN (SELECT UserID, UserName, Password FROM UsersTable WHERE UserName = '" + usrnmeLbl.Text + "')", conn); //SqlCommand comm = new SqlCommand("SELECT FamHistTable.Father FROM FamHistTable INNER JOIN UsersTable ON FamHistTable.UserID = UsersTable.UserID WHERE UsersTable.UserID = '" + usrnmeLbl.Text + "'", conn); SqlCommand comm = new SqlCommand("SELECT * FROM FatherHistTable, MotherHistTable, UsersTable WHERE UsersTable.UserName = '" + usrnmeLbl.Text + "'", conn); //Open connection conn.Open(); //Execute the command SqlDataReader reader = comm.ExecuteReader(); //Read and display the data while (reader.Read()) { string usr = reader["username"].ToString(); usr = usr.TrimEnd(); string pss = reader["password"].ToString(); pss = pss.TrimEnd(); if (usrnmeLbl.Text == usr) { if (hiddenpassLbl.Text == pss) { readDB_Lbl.Text += reader["username"] + "<br />"; //readDB_Lbl.Text += "Your User ID is: " + reader["UserID"] + "<br />"; readDB_Lbl.Text += "Your Father's name is: " + reader["Father"] + "<br />"; readDB_Lbl.Text += "Your Mother's name is: " + reader["Mother"] + "<br />"; } else { readDB_Lbl.Text = "User and Password mismatch."; } } } reader.Close(); conn.Close(); } } protected void updateBttn_Click(object sender, EventArgs e) { SqlCommand comm = new SqlCommand("UPDATE FatherHistTable SET " + "'famUpdteDDL.SelectedItem.Value'" + " = " + "'addPrsnTxtBx.Text'" + "WHERE UserName = " + "'usrnmeLbl.Text'"); }}
I try to run a webform with gridview which is using the sqldatasource to get the customer table from local database, AdventureWorks_Data.mdf, it throws the following error: Error: An attempt to attach an auto-named database for file C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataAdventureWorks_Data.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
I'm writing my first .net app in VB.net. I can connect to my database, but get the following error when I try to set a label value. (My code is listed below) What am I missing? Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present.Source Error:
Line 19: Line 20: reader = comm.ExecuteReader() Line 21: EmployeesLabel.Text = reader.Item("tkinit") Line 22: Line 23: reader.Close() <%@ Page Language="VB" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Configuration" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server">Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim conn As SqlConnectionDim comm As SqlCommand Dim reader As SqlDataReaderDim connectionString As String = ConfigurationManager.ConnectionStrings("IntegratedDataConnectionString").ConnectionString conn = New SqlConnection(connectionString) comm = New SqlCommand("Select top 1 tkinit from tEliteTimeKeep", conn) conn.Open()
I try to display normal gridview in a webform but it throws this error:
An attempt to attach an auto-named database for file C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataCommerce.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Line 45: Dim myAdapter As New SqlDataAdapter(myCommand)Line 46: myAdapter.Fill(myDataSet)Line 47: Line 48: gv_CashStatementList.DataSource = myDataSet Web.Config <add name="CommerceConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename="C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataCommerce.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient" />
My query actually returns rows but when I run, I get this error "Invalid attempt to read when no data is present". It says that the datareader does not return any rows. Please help. Thanks in advance Sangita
Hi all, I'm new to SSRS. I installed reporting services with my other services in SQL Server 2005. When I started Reporting Service Configuration tool,I see that my Reporting Server Status Stopped. When i am trying to start the service, i get the following error(exception)....also attached are the logfiles....
EXCEPTION DETAILS: System.ServiceProcess.TimeoutException: Time out has expired and the operation has not been completed. at System.ServiceProcess.ServiceController.WaitForStatus(ServiceControllerStatus desiredStatus, TimeSpan timeout) at ReportServicesConfigUI.Panels.ServerInformationPanel.StartStopServiceTask(Boolean start)
LOGFILE1: ----------------------- ------------------------------ ReportingServicesService!library!8!3/6/2008-20:26:48:: e ERROR: Sql error:System.Data.SqlClient.SqlException: Could not find stored procedure 'GetDBVersion'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) 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.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.ReportingServices.Library.InstrumentedSqlCommand.ExecuteNonQuery() at Microsoft.ReportingServices.Library.ConnectionManager.EnsureCorrectDBVersion() ReportingServicesService!library!8!3/6/2008-20:26:48:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.InvalidReportServerDatabaseException: The version of the report server database is either in a format that is not valid, or it cannot be read. The found version is 'Unknown'. The expected version is 'C.0.8.40'. To continue, update the version of the report server database and verify access rights., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.InvalidReportServerDatabaseException: The version of the report server database is either in a format that is not valid, or it cannot be read. The found version is 'Unknown'. The expected version is 'C.0.8.40'. To continue, update the version of the report server database and verify access rights. ReportingServicesService!library!8!3/6/2008-20:26:48:: Exception caught while starting service. Error: Microsoft.ReportingServices.Diagnostics.Utilities.InvalidReportServerDatabaseException: The version of the report server database is either in a format that is not valid, or it cannot be read. The found version is 'Unknown'. The expected version is 'C.0.8.40'. To continue, update the version of the report server database and verify access rights. at Microsoft.ReportingServices.Library.ConnectionManager.EnsureCorrectDBVersion() at Microsoft.ReportingServices.Library.ConnectionManager.ConnectStorage() at Microsoft.ReportingServices.Library.ServiceController.ServiceStartThread() ReportingServicesService!library!8!3/6/2008-20:26:48:: Attempting to start service again...
LOGFILE2: ------------ -------------------- ReportingServicesService!library!4!3/6/2008-20:26:47:: e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.UnknownUserNameException: The user or group name 'MACHINE_NAMEASPNET' is not recognized., ; Info: Microsoft.ReportingServices.Diagnostics.Utilities.UnknownUserNameException: The user or group name 'MACHINE_NAMEASPNET' is not recognized. ReportingServicesService!servicecontroller!9!3/6/2008-20:26:47:: Total Physical memory: 1063641088 ReportingServicesService!servicecontroller!4!3/6/2008-20:26:47:: e ERROR: Exception caught starting RPC server: Microsoft.ReportingServices.Diagnostics.Utilities.UnknownUserNameException: The user or group name 'MACHINE_NAMEASPNET' is not recognized. at Microsoft.ReportingServices.Library.Native.NameToSid(String name) at Microsoft.ReportingServices.Library.ServiceAppDomainController.StartRPCServer(Boolean firstTime)
Hi All,I think this is a thorny problem, and I'm hoping you can help. I've notfound this exact issue described anywhere yet.I have a stored procedure that calls BULK INSERT on a set of text files.These files are FTP'd from a legacy system (a mainframe running MVS).Sometimes, the process steps on iteslf, whereby the bulk insert is attemptedon a file whose FTP is still in progress; it's not fully written to disk onthe SQL box (it's a 100MB file that takes a long time to cross the networkto the share on the Windows box), and so the insert generates a fatal errorand the procedure stops.I wrote a proc that calls the sp_OA* procs to use theScripting.FileSystemObject to test for the file's readiness. It returns anerror for me if the file does not exist. It also returns an error if I tryto run the BULK INSERT against a file which is being copied via Windows tothe SQL box. This is working just fine under those conditions; thesp_OAMethod to call OpenTextFile bombs appropriately if the file write isstill in progress.That's great, but it doesn't do the same thing during an FTP in progress.It doesn't generate the same error (that is OpenTextFile has no problemopening a partially written FTP'd file). I can also open the file inNotepad, even though it's not fully written to disk ... something I did notexpect, but there we are. What is it about FTP that's different from aWindows file system copy operation that makes the file look available forreading?If BULK INSERT is capable of detecting that it cannot do its thing on a filewhose FTP is in progress, then what can I write or call to emulate thatdetection? I tried writing a COM object in VB.NET and calling that from mySQL stored proc instead of the Scripting Engine's FSO methods. My codesimlpy tries to run a FileOpen using an Exclusive read lock; however, thisdoesn't seem to work, and I'm shooting in the dark now.Can anyone tell me what kind of file i/o request BULK INSERT makes, suchthat it is capable of abending during a run against an incompletely writtenfile using FTP?Thanks!Tim
SQL SERVER 2000Hi allThis is my first attempt at writing a stored procedure. I have managed toget it working but its unlikely to be the best way of handling the problem.While writing it I found some things that I don't understand so if any onecould shed any light it would be much appreciated. I have posted these atthe end.Sorry about the length but I thought it might be worthwhile posting the codeThe purpose of the procedures is as follows : we have a view of lots of bitsof information that need automatically mailing to different people. eachelement of information has a name allocated against it. If we had 100 piecesof data, 50 could go to manager 1 25 could go to manager 2 and 25 to manager3 etc...Both SP's look at the same viewThe first SP generates a distinct list of managers and for each managercalls the second SPThe second SP filters the view for the data belonging to the selectedmanager, and builds an HTML mail. It then sends all the bits of informationbelonging to that manager off in an EMAIL to him/her. ( It uses a brilliantbit of code from sqldev.net to handle the mail)the first mail then repeats for all the managers in the listCODE ---- SP 1ALTER PROCEDURE dbo.PR_ADMIN_CLIENT_WEEKLY_NOTIFICATION_2ASbeginSET NOCOUNT ONdeclare @no_of_managers as intdeclare @current_record as intdeclare @manager_name as varchar(100)-- count how many distinct managers we need to send the mail toselect @no_of_managers = COUNT(DISTINCT manager_name) FROMdbo.vw_client_notification_email_1-- open a cursor to the same distinct listdeclare email_list cursor for select distinct manager_name fromdbo.vw_client_notification_email_1 dscopen email_list-- for each distinct manager get the managers name and pass it to the storedprocedure that generates the mail.set @current_record = 0while (@current_record) < @no_of_managersbeginfetch next from email_list into @manager_nameEXECUTE dbo.pr_admin_client_weekly_notification @manager_nameset @current_record = @current_record+1end-- close the cursorclose email_listdeallocate email_listendCODE ---- SP2ALTER PROCEDURE dbo.PR_ADMIN_CLIENT_WEEKLY_NOTIFICATION(@current_manager_name as varchar(100))-- a unique managers name is passed from the calling procedureas beginSET NOCOUNT ON-- declarations for use in the stored procedureDECLARE @to as varchar(100)DECLARE @entry varchar(500)DECLARE @region as varchar(100)DECLARE @type as varchar(100)DECLARE @site_ref as varchar(100)DECLARE @aborted as varchar(100)DECLARE @weblink as varchar(1000)DECLARE @manager_name as varchar(100)DECLARE @manager_email as varchar(100)DECLARE @body VARCHAR(8000)DECLARE @link varchar(150)DECLARE @web_base VARCHAR(150)-- set up a connection to the view that contains the details for the mailDECLARE email_contents cursor for select region,type,site_ref,aborted_visit,link,manager_name,manager_e mail fromvw_client_notification_email_1 where manager_name = @current_manager_nameopen email_contents--some initial textset @body = '<font color="#FF8040"><b>Reports W/E ' +convert(char(50),getdate()) + '</b></font><br><br> <a href = http://xxxx > Click here to logon to xxxxx </a><br><br> '--fetch the first matching record from the table and build the body of themessagefetch next from email_contents into@region,@type,@site_ref,@aborted,@link,@manager_na me,@manager_emailset @web_base = 'http://'set @weblink = @web_base + @linkif @aborted = 0 set @aborted = '' else set @aborted = 'ABORTED'set @body = @body + '<font size="2"><b> Region </b>' + @region+ ' <b>Type</b> ' + @type+ ' <b>Site Reference </b> <a href = "' + @weblink + '">' + @site_ref+'</a>'+ ' <b>Unique Report Reference </b>' + @link + '<br>'-- continue reading the records for this particular message and adding on tothe body of the textwhile(@@fetch_status = 0)beginfetch next from email_contents into@region,@type,@site_ref,@aborted,@link,@manager_na me,@manager_emailif @aborted = 0 set @aborted = '' else set @aborted = 'ABORTED'if (@@fetch_status = 0) set @body = @body + '<b> Region </b>' + @region+ ' <b>Type</b> ' + @type+ ' <b>Site Reference </b> <a href = "' + @weblink + '">' + @site_ref+'</a>'+ '<b>Unique Report Reference </b>' + @link + '<br>'end-- close the cursorset @body = @body + '</font>'close email_contentsdeallocate email_contents-- generate the mailDECLARE @rc int EXEC @rc = master.dbo.xp_smtp_sendmail@FROM = N'FROM ME',@TO = @manager_email,@server = N'server',@subject = N'Weekly Import',@message = @body,@type = N'text/html'endQuestionsis the way I've done it OK. I thought I would be able to do it in a singleSP but I really struggled nesting the cursor things.@@fetchstatus seems to be global, so if your using nested cursors, how doyou know which one you are refering to. If you have multiple calls to thesame SP how does it know which instance of the SP it refers to.When I first wrote it, I used a cursor in SP1 to call SP2, but I couldn'tget the while loop working - I have a feeling it was down to the @@fetchstatus in the 'calling' procedure being overwritten by the@@fetchstatus in the 'called' procedure.The whole @@fetchatus thing seems a bit odd. In the second procedure, I haveto fetch, then check, manipulate then fetch again, meaning that the samemanipulation code is written twice. thats why in the first procedure I usedthe select distint count to know how long the record set is so I only haveto run the manipulation code once. Is what I have done wrong?its possible that the body of the mail could be > 8K, is there anotherdatatype I can use to hold more than 8Kmany thanks for any help or adviceAndy
I have a stored procedure that inserts a record, and then either returns an error or, when successful, returns the entire row. This is a method I use on sites I have developed in other languages when inserting or updating data; I am new to c#.
With C# I have a datareader executing the sp, and the insert works fine, however I get the error "Invalid attempt to read when no data is present." when I try to read the data that should be coming back. I have researched and updated my code so that I no longer get the error, but I still cannot get the data back. I trap the sp in profiler, ran it in anaylzer, and it works fine - data is returned. But in the code, it does not see the data.
I have modified the return results so now I just have the ID coming back and that works fine. But I would rather just return the entire row. Can this be done, and if so, how?