Infinite Array in C#

by Damiaan Peeters 31. January 2008 08:11

In VB you can ReDim an array.

In C# there is nothing such as a Redim Preserve.  You can only copy everything into a new array like this
string [] names2 = new string[7];
Array.Copy(names, names2, names.Lenght);


When using .Net 2.0 or later, I would suggest using Generics.  You can use generics like this
for a list of strings:
List<string> names = new List<string>();
Or a list of objects:
List <myClass> myList = new List<myClass>();

If you want an infinit 'Array' of int's you can use:
List <int> myRow = new List<int>();
List <myRow> infinitArray = new List<myRow>();

 

Tags: ,

C#

PDF in Microsoft Access

by Damiaan Peeters 30. January 2008 09:46

Even een korte uitleg hoe deze werken.
Je hebt 2 delen.
1) De printer
De printer is meestal niet meer dan een printer met een gewone generic Printer driver die PostScript (PS) creert.  
Als je de driver zo instelt dat alles wordt opgeslagen naar een bestand, dan kan het tweede deel in gang treden.
2) de PDF generator  (zeg maar de acrobat distiller)
Als een nieuw bestand wordt ontdekt in een bepaalde directory, dan wordt de PostScript omgezet naar PDF.  Aangezien de gelijkenis hier zeer groot is, doen deze programma's dat zonder problemen.

[more]
Een gratis programma dat dit doet is GhostScript (http://pages.cs.wisc.edu/~ghost/doc/GPL/index.htm).  Dit wordt ook regelmatig gebruikt door andere PDF Printers.

Ik heb enkele programma's gevonden die een DEVELOPER API aanbieden.  Deze zijn meestal vrij duur voor zover ik prijzen heb teruggevonden.  De prijzen varieerden tussen de paar honderd dollar en zelfs meer dan 1000 dollar.

  • PrimoPDF (http://www.primopdf.com/)
  • ActivePDF: gelinkt aan PrimoPdf volgens mij, én zeer duur http://www.activepdf.com/
  • CutePDF: maakt overigens gebruik van Ghostscript. (http://www.cutepdf.com/Products/CutePDF/writer.asp)
  • ExpertPDF (http://www.html-to-pdf.net)
Enkele alternatieven (zonder dev. api), maar wél gratis.

  • PDF4Free (gratis) http://www.pdfpdf.com/pdf4free.html
  • Bullzip Pdf Printer (gratis) http://www.bullzip.com/products/pdf/info.php
...  Hier vind je er zéér veel van terug.  Opgelet sommigen hebben reclame aan boord...

Andere formaten

Waarom PDF?  Er zijn ook alternatieven die goed verspreid zijn...
Microsoft heeft er 2 in petto.

De eerste noemt  MDI (Microsoft Office Document Image Format), zit in de office versies vanaf Office XP dacht ik.
(http://office.microsoft.com/en-gb/help/HP010771031033.aspx)
Een whitepaper hierover (niet gelezen): Office 2003: Microsoft Office Document Imaging Visual Basic Reference (MODI) (exe): 

XPS kan je gebruiken als je hetzelfde effect wil, maar gebaseerd op XML!
Dit zou naar de toekomst toe dus veiliger zijn dan een propriaty format...
Hier kan je de viewer & writer downloaden indien je die nog niet zou hebben: http://www.microsoft.com/whdc/xps/viewxps.mspx
Dit is een printer driver en vervangt dus alle bovenstaande rommel (!).

Hoe te gebruiken

Voila... Dat is een hele brok.  Pdf, xps, mdi, ...  Maar dan heb je natuurlijk enkel (virtuele) printers.
Dan moet je in VBA de code hebben om zo'n printer aan te sturen, maar dat lijkt niet zo moeilijk te zijn.  Ik heb net dit (http://www.vbaexpress.com/forum/archive/index.php/t-4205.html) gevonden voor excel, maar ik vermoed dat het in Access niet veel anders zal zijn?

Sub Macro1()
Application.ActivePrinter = "Microsoft Office Document Image Writer on Ne01:"
ActiveSheet.PrintOut PrToFileName:="C:\Atest1.mdi"
End Sub 
Volgens mij werkt dit soort code met ongeveer ELKE virtuele printer die hierboven is beschreven.
Als je het mij zou vragen, probeer MDI en XPS zeker eens uit!  Het klinkt niet zo sexy als PDF, maar het is ook de moeite waard volgens mij.  En zoals gezegd, dat gaat voor elke virtuele printer werken...  

Zo ... Ik hoop dat je er iets mee bent.

Restore tool Windows XP

by Damiaan Peeters 8. January 2008 15:57

Ever had problems with the restore tool?

Here you can see how to start the System Restore tool at a command prompt in Windows XP

Bart De Smet gone mad about Extension methods

by Damiaan Peeters 7. January 2008 16:56

Our beloved Bart De Smet has gone mad.  Complete insane.  He started to add some Extension Methods to do Exception handling. 

He writes the following on his blog:

What a joke you must think when reading this post's title. Isn't the functional paradigm all about side-effect free programming and the such? Well, it turns out you're absolutely right. So, why this post? I have to admit I had yet another crazy Sunday afternoon idea that I found worthwhile to open VS 2008 for and give it a short.  Exception Handling in functional style - B# .NET Blog

You read it well.  "Another crazy Sunday".  It appears that working at Microsoft has some side effects.

Apart from the crazy Sundays Bart, created to a few 5 star Webcasts about C# 3.0.

Launch Visual Studio 2008 Belgium

by Damiaan Peeters 6. January 2008 15:24

Heroes Happen Here it is called. Go to http://www.heroeshappenhere.be

Heroes Happen Here is the main theme of an impressive launch.
With it, Microsoft honours the talent of all of our users who transform our products into powerful products for solving real work IT problems.

On Launch day March 11, we'll officially present new versions of Windows Server 2008, Microsoft SQL Server 2008 and Microsoft Visual Studio 2008.

On March 12 and March 13 we stage the TechDays. During workshops IT professionals and developers alike get a chance to go into every single asset of each pack.

The program for the technical sessions on March 12 and 13 are still not available, but i guess this will be soon the case.

Let's meet in Gent.

BlogEngine.Net SQL Update Script

by Damiaan Peeters 2. January 2008 14:12

I am using a great tool called SQL Examiner. 

Using this tool i created a "update" script for BlogEngine 1.3.  (from version 1.2).

Replace the "yourdatabasename" by the name of your database.

[more]

 

/*
Script created by SQL Examiner 1.6.0.42 at 01/02/2008 13:43:38 
Upgrade SQL Database from 1.2 to version 1.3
*/
--step 1. Backup database
BACKUP DATABASE [yourDatabaseName] TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\yourDatabaseName_db_200801021343.bak' WITH  INIT,  NOUNLOAD,  NAME = N'yourDatabaseName backup', NOSKIP, DESCRIPTION = N'SQL Examiner Backup', NOFORMAT
GO
USE [yourDatabaseName]
GO
SET NOCOUNT ON
SET NOEXEC OFF
SET ARITHABORT ON
SET XACT_ABORT ON
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRAN
GO
--step 2: add columns to Table dbo.be_Categories----------------------------------------------------
GO
ALTER TABLE [dbo].[be_Categories] ADD 
[Description]	[nvarchar](200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 2 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 2 is completed with errors' SET NOEXEC ON END
GO
--step 3: alter column [CategoryName] of table [dbo].[be_Categories]--------------------------------
GO
ALTER TABLE [dbo].[be_Categories] ALTER COLUMN [CategoryName] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 3 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 3 is completed with errors' SET NOEXEC ON END
GO
--step 4: alter column [Title] of table [dbo].[be_Pages]--------------------------------------------
GO
ALTER TABLE [dbo].[be_Pages] ALTER COLUMN [Title] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 4 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 4 is completed with errors' SET NOEXEC ON END
GO
--step 5: alter column [Description] of table [dbo].[be_Pages]--------------------------------------
GO
ALTER TABLE [dbo].[be_Pages] ALTER COLUMN [Description] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 5 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 5 is completed with errors' SET NOEXEC ON END
GO
--step 6: alter column [Keywords] of table [dbo].[be_Pages]-----------------------------------------
GO
ALTER TABLE [dbo].[be_Pages] ALTER COLUMN [Keywords] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 6 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 6 is completed with errors' SET NOEXEC ON END
GO
--step 7: alter column [Link] of table [dbo].[be_PingService]---------------------------------------
GO
ALTER TABLE [dbo].[be_PingService] ALTER COLUMN [Link] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 7 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 7 is completed with errors' SET NOEXEC ON END
GO
--step 8: dbo.be_PostCategory: add foreign key FK_be_PostCategory_be_Categories---------------------
GO
ALTER TABLE [dbo].[be_PostCategory] ADD CONSTRAINT [FK_be_PostCategory_be_Categories] FOREIGN KEY ([CategoryID]) REFERENCES [dbo].[be_Categories] ([CategoryID])
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 8 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 8 is completed with errors' SET NOEXEC ON END
GO
--step 9: alter column [Title] of table [dbo].[be_Posts]--------------------------------------------
GO
ALTER TABLE [dbo].[be_Posts] ALTER COLUMN [Title] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 9 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 9 is completed with errors' SET NOEXEC ON END
GO
--step 10: alter column [Description] of table [dbo].[be_Posts]-------------------------------------
GO
ALTER TABLE [dbo].[be_Posts] ALTER COLUMN [Description] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 10 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 10 is completed with errors' SET NOEXEC ON END
GO
--step 11: alter column [Author] of table [dbo].[be_Posts]------------------------------------------
GO
ALTER TABLE [dbo].[be_Posts] ALTER COLUMN [Author] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 11 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 11 is completed with errors' SET NOEXEC ON END
GO
--step 12: alter column [Slug] of table [dbo].[be_Posts]--------------------------------------------
GO
ALTER TABLE [dbo].[be_Posts] ALTER COLUMN [Slug] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 12 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 12 is completed with errors' SET NOEXEC ON END
GO
--step 13: dbo.be_PostCategory: add foreign key FK_be_PostCategory_be_Posts-------------------------
GO
ALTER TABLE [dbo].[be_PostCategory] ADD CONSTRAINT [FK_be_PostCategory_be_Posts] FOREIGN KEY ([PostID]) REFERENCES [dbo].[be_Posts] ([PostID])
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 13 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 13 is completed with errors' SET NOEXEC ON END
GO
--step 14: add index FK_CategoryID to table dbo.be_PostCategory-------------------------------------
GO
CREATE NONCLUSTERED INDEX [FK_CategoryID] ON [dbo].[be_PostCategory]([CategoryID]) ON [PRIMARY]
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 14 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 14 is completed with errors' SET NOEXEC ON END
GO
--step 15: add index FK_PostID to table dbo.be_PostCategory-----------------------------------------
GO
CREATE NONCLUSTERED INDEX [FK_PostID] ON [dbo].[be_PostCategory]([PostID]) ON [PRIMARY]
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 15 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 15 is completed with errors' SET NOEXEC ON END
GO
--step 16: alter column [Author] of table [dbo].[be_PostComment]------------------------------------
GO
ALTER TABLE [dbo].[be_PostComment] ALTER COLUMN [Author] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 16 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 16 is completed with errors' SET NOEXEC ON END
GO
--step 17: alter column [Email] of table [dbo].[be_PostComment]-------------------------------------
GO
ALTER TABLE [dbo].[be_PostComment] ALTER COLUMN [Email] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 17 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 17 is completed with errors' SET NOEXEC ON END
GO
--step 18: alter column [Website] of table [dbo].[be_PostComment]-----------------------------------
GO
ALTER TABLE [dbo].[be_PostComment] ALTER COLUMN [Website] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 18 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 18 is completed with errors' SET NOEXEC ON END
GO
--step 19: alter column [Comment] of table [dbo].[be_PostComment]-----------------------------------
GO
ALTER TABLE [dbo].[be_PostComment] ALTER COLUMN [Comment] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 19 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 19 is completed with errors' SET NOEXEC ON END
GO
--step 20: alter column [Country] of table [dbo].[be_PostComment]-----------------------------------
GO
ALTER TABLE [dbo].[be_PostComment] ALTER COLUMN [Country] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 20 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 20 is completed with errors' SET NOEXEC ON END
GO
--step 21: alter column [Ip] of table [dbo].[be_PostComment]----------------------------------------
GO
ALTER TABLE [dbo].[be_PostComment] ALTER COLUMN [Ip] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 21 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 21 is completed with errors' SET NOEXEC ON END
GO
--step 22: dbo.be_PostComment: add foreign key FK_be_PostComment_be_Posts---------------------------
GO
ALTER TABLE [dbo].[be_PostComment] ADD CONSTRAINT [FK_be_PostComment_be_Posts] FOREIGN KEY ([PostID]) REFERENCES [dbo].[be_Posts] ([PostID])
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 22 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 22 is completed with errors' SET NOEXEC ON END
GO
--step 23: add index FK_PostID to table dbo.be_PostComment------------------------------------------
GO
CREATE NONCLUSTERED INDEX [FK_PostID] ON [dbo].[be_PostComment]([PostID]) ON [PRIMARY]
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 23 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 23 is completed with errors' SET NOEXEC ON END
GO
--step 24: alter column [NotifyAddress] of table [dbo].[be_PostNotify]------------------------------
GO
ALTER TABLE [dbo].[be_PostNotify] ALTER COLUMN [NotifyAddress] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 24 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 24 is completed with errors' SET NOEXEC ON END
GO
--step 25: dbo.be_PostNotify: add foreign key FK_be_PostNotify_be_Posts-----------------------------
GO
ALTER TABLE [dbo].[be_PostNotify] ADD CONSTRAINT [FK_be_PostNotify_be_Posts] FOREIGN KEY ([PostID]) REFERENCES [dbo].[be_Posts] ([PostID])
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 25 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 25 is completed with errors' SET NOEXEC ON END
GO
--step 26: add index FK_PostID to table dbo.be_PostNotify-------------------------------------------
GO
CREATE NONCLUSTERED INDEX [FK_PostID] ON [dbo].[be_PostNotify]([PostID]) ON [PRIMARY]
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 26 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 26 is completed with errors' SET NOEXEC ON END
GO
--step 27: alter column [Tag] of table [dbo].[be_PostTag]-------------------------------------------
GO
ALTER TABLE [dbo].[be_PostTag] ALTER COLUMN [Tag] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 27 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 27 is completed with errors' SET NOEXEC ON END
GO
--step 28: dbo.be_PostTag: add foreign key FK_be_PostTag_be_Posts-----------------------------------
GO
ALTER TABLE [dbo].[be_PostTag] ADD CONSTRAINT [FK_be_PostTag_be_Posts] FOREIGN KEY ([PostID]) REFERENCES [dbo].[be_Posts] ([PostID])
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 28 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 28 is completed with errors' SET NOEXEC ON END
GO
--step 29: add index FK_PostID to table dbo.be_PostTag----------------------------------------------
GO
CREATE NONCLUSTERED INDEX [FK_PostID] ON [dbo].[be_PostTag]([PostID]) ON [PRIMARY]
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 29 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 29 is completed with errors' SET NOEXEC ON END
GO
--step 30: dbo.be_Settings: drop primary key PK_be_Settings-----------------------------------------
GO
ALTER TABLE [dbo].[be_Settings] DROP CONSTRAINT [PK_be_Settings]
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 30 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 30 is completed with errors' SET NOEXEC ON END
GO
--step 31: alter column [SettingName] of table [dbo].[be_Settings]----------------------------------
GO
ALTER TABLE [dbo].[be_Settings] ALTER COLUMN [SettingName] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 31 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 31 is completed with errors' SET NOEXEC ON END
GO
--step 32: alter column [SettingValue] of table [dbo].[be_Settings]---------------------------------
GO
ALTER TABLE [dbo].[be_Settings] ALTER COLUMN [SettingValue] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 32 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 32 is completed with errors' SET NOEXEC ON END
GO
--step 33: drop schema blog-dampee------------------------------------------------------------------
GO
DROP SCHEMA [blog-dampee]
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 33 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 33 is completed with errors' SET NOEXEC ON END
GO
--step 34: dbo.be_Settings: add primary key PK_be_Settings------------------------------------------
GO
ALTER TABLE [dbo].[be_Settings] ADD CONSTRAINT [PK_be_Settings] PRIMARY KEY CLUSTERED ([SettingName])
GO
IF @@ERROR <> 0 AND @@TRANCOUNT > 0 BEGIN PRINT 'step 34 is completed with errors' ROLLBACK TRAN END
GO
IF @@TRANCOUNT = 0 BEGIN PRINT 'step 34 is completed with errors' SET NOEXEC ON END
GO
----------------------------------------------------------------------
IF @@TRANCOUNT > 0 BEGIN COMMIT TRAN PRINT 'Synchronization is successfully completed.' END
GO

Connectionstring in another Project (DLL)

by Damiaan Peeters 1. January 2008 16:49

I always put my datalogic into a different project.  Like this i can reuse my DL in other projects with the same purpose or customer.  [more]

To change or get a connectionstring is normally impossible because the Settings class is declared as internal.  This means that the complete project is able to access this property, but other projects (dll's) are not allowed to access this property.

If you try to access this, you will see get an error like this:

'DamPee.MyProject.DL.Properties.Settings' is inaccessible due to its protection level   

If you open the Settings, you will see the Access Modifier.  Change this to Public.

image

 

Now you will be able to access the Settings (including the connectionstrings) in your other projects.

connection.ConnectionString = global::DamPee.MyProject.DL.Properties.Settings.Default.MyProjectConnectionString;
connection.Open();

Who.I.am

Certified Umbraco, .net and Azure developer, seo lover. Magician in my spare time.

Month List