Author: Ashish Gupta
Gios PDF .NET library
Very sleek open source PDF creation library built in .NET and its up for commercial use.
http://www.codeproject.com/KB/graphics/giospdfnetlibrary.aspx
Use sections in the config file and access them…
(
NameValueCollection)ConfigurationManager.GetSection("applicationSettings/ConnectionStrings");Visual studio 2005 Build error :- The volume for a file has been externally altered so that the opened file is no longer valid
Convert string to byte array and viceversa
string elementStringContent = System.Text.Encoding.UTF8.GetString(elementByteContent);
elementStringContent = elementStringContent.Replace(" ", "");
if (elementStringContent == string.Empty)
{
elementStringContent = "<P> </P>";
contentObject.Content = System.Text.Encoding.UTF8.GetBytes(elementStringContent);
}
Removing comments using XPathNavigator.SelectDescendants(System.Xml.XPath.XPathNodeType.Comment,false);
#region
Remove XML commentsSystem.Xml.XPath.XPathNavigator path = xmlDoc.SelectSingleNode("w:document",xmlNSMgr).CreateNavigator();
System.Xml.XPath.XPathNodeIterator commentsIterator = path.SelectDescendants(System.Xml.XPath.XPathNodeType.Comment,false);
if (commentsIterator.Count > 0)
{
while (commentsIterator.MoveNext())
{commentsIterator.Current.DeleteSelf();}}
#endregion
For the following XML:-(We needed to remove "<!– Generated by Aspose.Words for .NET 4.4.1.0 –> ")
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
– <w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml">
– <!– Generated by Aspose.Words for .NET 4.4.1.0
–>
– <w:body>
– <w:p>
– <w:r>
– <w:rPr>
<w:b />
<w:color w:val="FF0000" />
<w:sz w:val="24" />
</w:rPr>
<w:t>Evaluation Only. Created with Aspose.Words. Copyright 2003-2007 Aspose Pty Ltd.</w:t>
</w:r>
</w:p>
</w:body>
</w:document>
Process.Start() – Open the file from the application after writing on the file
using System.Diagnostics;
XmlDocument Xdoc = new XmlDocument();
string folderPath = @"C:\Ashish\";
string upload = folderPath + "2007.docx";
string savename = folderPath + "WordPackage.xml";
ZipPackage zipPackage = null;
byte[] packageData = null;
Stream stream;
packageData = GetBytesFromFile(upload);
stream = new MemoryStream(packageData);
if (stream != null)
zipPackage = GetZipPackageFromStream(stream);
Xdoc = RRD.DSA.SCP.OfficeAssembler.WordToXyXmlAssembler.ConvertToXyXml(zipPackage);
Xdoc.Save(savename); // Following line would open the saved file in its default application (Internet explorer)
Process.Start(strSave);
Checking for the existence of a temporary table
IF object_id('tempdb..#MyTempTable') IS NOT NULL
BEGIN
DROP TABLE #MyTempTable
PRINT 'Table dropped'
END
CREATE TABLE #MyTempTable
(
ID int IDENTITY(1,1),
SomeValue varchar(100)
)
GO
Returning value from sp_executesql
DECLARE @Count int
execute sp_executesql
N’select @Count = COUNT(*) from Northwind.dbo.Orders’,
N’@Count int OUT’, @Count OUT
SELECT @Count
can not drop user from database
the message errror is :
TITLE: SQL Server Management Studio
—————————————-
Drop failed for User ‘Amministratore’. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft SQL Server&ProdVer=9.00.0981.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Drop+User&LinkId=20476
—————————————-
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
—————————————-
The database principal owns a schema and cannot be dropped. (Microsoft SQL Server, Error: 15138)
Solution:-
1) Expand Schemas(should be like a folder under <yourdatabase> -> Security) .
2) Script the the unwanted "userSchema" save it and and then Delete the schema.
3) Then, go back to the User,script the user and then delete the user.
4) Associate the schema back to the user by running the script.