Posts Tagged ‘C#’

Paradox Direct Engine (ActiveX edition) v2.95

Wednesday, March 11th, 2015

Paradox Direct Engine (ActiveX edition) v2.95
http://www.scalabium.com/pdx/pdxa.htm

The new SaveToXML method you may generate the xml-file which is compatible with .NET DataSet class.
Now you may do not use the ado recordset and load the xml directly in Dataset().
For example:

// create unbound recordset for temporary storage (from Paradox table)
DataTable table1 = new DataTable("country");
table1.Columns.Add("Name");
table1.Columns.Add("Capital");
table1.Columns.Add("Continent");
table1.Columns.Add("Area");
table1.Columns.Add("Population");
 
DataSet set = new DataSet("map");
set.Tables.Add(table1);
 
// convert the records in Paradox table to xml-file
PdxViewA.TScalabiumParadoxReader pdx = new PdxViewA.TScalabiumParadoxReader();
pdx.FileName = Application.StartupPath + "\\country.db";
pdx.SaveToXML(Application.StartupPath + "\\country.xml", "country", false);
if (pdx.LastErrorMessage != null)
MessageBox.Show(pdx.LastErrorMessage);
 
//load converted xml into dataset
set.ReadXml(Application.StartupPath + "\\country.xml");
 
//view records in datagrid
dataGridView1.DataSource = table1;

C# and MS SQL Server: add System.Drawing assembly

Wednesday, August 11th, 2010

Working with images in SQL Server 2005 is not easy because the System.Drawing.dll is not included in the assemblies with SQL Server.

This library was not added because it does not pass the CLR Verifier, and it has not been fully tested in SQL Server hosted environment (i.e. it could damage the stability and security of SQL Server). Careful consideration should be taken when attempting to manipulate images (or even load images from a file system or webservice).

To add the System.Drawing.dll assembly to SQL Server use the new create assembly statement. The database you are adding this assembly to must have its TrustWorthy property turned on. The following code demonstrates how to add System.Drawing.dll to the ImageGen database.

ALTER DATABASE yourDatabase
SET TRUSTWORTHY ON
GO
CREATE ASSEMBLY [System.Drawing]
FROM 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll'
WITH PERMISSION_SET = UNSAFE
GO

Now a managed stored procedure can be created that uses the System.Drawing.dll assembly as shown below (although do not forget to add the assembly reference in the VS project).

using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Drawing;
using System.Drawing.Imaging;