Andreas Kviby - The DotNetNerd

Every breath I take it's between those { }!
Dell Latitude XT2 - Tablet PC

Fick äran att låna en Dell Latitude XT2 från Tankbar - Webbyrån i Nyköping (www.tankbar.com) och det resulterade i ett tekniktest som jag verkligen kan rekommendera er tekniknördar att läsa.

Läs inlägget på SN här

Posted: 03-15-2010 0:09 by diaz.net with no comments

Backup all databases in SQL Server Express editions

I have been searching and wanting a good but simple backup solution for all my SQL Server 2008 and SQL Server 2005 databases in the free Express edition. There is as you know no maintainance plans in the express editions and they are not backed up correctly by server software built in your server os. So finally I did stumble upon a really great solution which I modified a bit and will share here for all my friends and others to use.

The whole idea is to backup all databases inside a named instance and also to keep track on how many days you want to save the backed up files.

I use this for my local SharePoint backups and also three servers with SQL Server. Fantastic!

image

My folderstructure looks like above and you can ofcourse name files and scripts and folders the way you want it.

I have a folder on my root drive or data drive on my server called sqlbackup. Inside that folder I have the above structure setup. I also have a subfolder called dbfiles and in that folder all my backups will be stored.

backupscript.sql

First of all we create the backupscript.sql file and it should look like the below file contents.

 

DECLARE @dateString CHAR(12), @dayStr CHAR(2), @monthStr CHAR(2), @hourStr CHAR(2), @minStr CHAR(2)

--month variable

IF (SELECT LEN(CAST(MONTH(GETDATE()) AS CHAR(2))))=2

   SET @monthSTR=CAST(MONTH(GETDATE()) AS CHAR(2))

ELSE

   SET @monthSTR= '0' + CAST(MONTH(GETDATE()) AS CHAR(2))

--day variable

IF (SELECT LEN(CAST(DAY(GETDATE()) AS CHAR(2))))=2

   SET @daySTR=CAST(DAY(GETDATE()) AS CHAR(2))

ELSE

   SET @daySTR='0' + CAST(DAY(GETDATE()) AS CHAR(2))

--hour variable

IF (SELECT LEN(DATEPART(hh, GETDATE())))=2

   SET @hourStr=CAST(DATEPART(hh, GETDATE()) AS CHAR(2))

ELSE

   SET @hourStr= '0' + CAST(DATEPART(hh, GETDATE()) AS CHAR(2))

--minute variable

IF (SELECT LEN(DATEPART(mi, GETDATE())))=2

   SET @minStr=CAST(DATEPART(mi, GETDATE()) AS CHAR(2))

ELSE

   SET @minStr= '0' + CAST(DATEPART(mi, GETDATE()) AS CHAR(2))

--name variable based on time stamp

SET @dateString=CAST(YEAR(GETDATE()) AS CHAR(4)) + @monthStr + @dayStr + @hourStr + @minStr

--=================================================================

DECLARE @IDENT INT, @sql VARCHAR(1000), @DBNAME VARCHAR(200)

SELECT @IDENT=MIN(database_id) FROM SYS.DATABASES WHERE [database_id] > 0 AND NAME NOT IN ('TEMPDB')

WHILE @IDENT IS NOT NULL

BEGIN

   SELECT @DBNAME = NAME FROM SYS.DATABASES WHERE database_id = @IDENT

/*Change disk location here as required*/

   SELECT @SQL = 'BACKUP DATABASE '+@DBNAME+' TO DISK = ''c:\sqlbackup\dbfiles\'+@DBNAME+'_db_' + @dateString +'.BAK'' WITH INIT'

   EXEC (@SQL)

   SELECT @IDENT=MIN(database_id) FROM SYS.DATABASES WHERE [database_id] > 0 AND database_id>@IDENT AND NAME NOT IN ('TEMPDB')

END

Remember to change the path c:\sqlbackup\dbfiles in the script above if you change your path!

So the sqlscript will backup all databases in a named instance and save them to the dbfiles folder marked with date and time.

Now we will create the clearbackup.vbs script that will delete backup files older than x days in the dbfiles folder.

clearbackup.vbs

On Error Resume Next 
Dim fso, folder, files, sFolder, sFolderTarget   
Set fso = CreateObject("Scripting.FileSystemObject") 

'location of the database backup files
sFolder = "c:\sqlbackup\dbfiles"

Set folder = fso.GetFolder(sFolder) 
Set files = folder.Files   

'used for writing to textfile - generate report on database backups deleted
Const ForAppending = 8

'you need to create a folder named “scripts” for ease of file management &
'a file inside it named “LOG.txt” for delete activity logging
Set objFile = fso.OpenTextFile("c:\sqlbackup\LOG.txt", ForAppending)

objFile.Write "================================================================" & VBCRLF & VBCRLF
objFile.Write "                     DATABASE BACKUP FILE REPORT                " & VBCRLF
objFile.Write "                     DATE:  " &    FormatDateTime(Now(),1)   & "" & VBCRLF
objFile.Write "                     TIME:  " &    FormatDateTime(Now(),3)   & "" & VBCRLF & VBCRLF
objFile.Write "================================================================" & VBCRLF

'iterate thru each of the files in the database backup folder
For Each itemFiles In files
   'retrieve complete path of file for the DeleteFile method and to extract
        'file extension using the GetExtensionName method
   a=sFolder & itemFiles.Name

   'retrieve file extension
   b = fso.GetExtensionName(a)
       'check if the file extension is BAK
       If uCase(b)="BAK" Then

           'check if the database backups are older than 5 days
           If DateDiff("d",itemFiles.DateCreated,Now()) >= 5 Then

               'Delete any old BACKUP files to cleanup folder
               fso.DeleteFile a
               objFile.WriteLine "BACKUP FILE DELETED: " & a
           Else
              objFile.WriteLine "BACKUP FILE IS STILL CURRENT: " & a
           End If
       End If
Next 

objFile.WriteLine "================================================================" & VBCRLF & VBCRLF

objFile.Close

Set objFile = Nothing
Set fso = Nothing
Set folder = Nothing
Set files = Nothing

Change the x number of days to match you wishes!

log.txt

Create a textfile called log.txt in the folder so that the script can append logs to it. The logfile will contain the log for backing up files and deleting old backup files.

Now we will create the command batch file that we can schedule on the server to execute whenever we feel neccessary.

runsqlbackups.cmd

The file will look like below.

REM Run TSQL Script to backup databases
sqlcmd -S AKVIBY\SQLEXPRESS -E -i"c:\sqlbackup\backupscript.sql"

REM Run database backup cleanup script
c:\sqlbackup\clearbackup.vbs

 

Remember to change instance and path to match your settings!

So schedule your runsqlbackups.cmd and it will backup all your files and store them in dbfiles folder which you can make sure is backed up on regular times by your server backup system.

When you run the scheduled task you will se a command prompt like below.

image

If everything is setup okey you will also find all backups inside the dbfiles folder.

image

Like my local backups you can see above I then mark the dbfiles folder as an Live Mesh folder and all backed up.

That’s all folks!

Posted: 10-02-2009 17:54 by diaz.net with no comments

How to send Mail from Outlook to SharePoint

I will start a step by step tutorial here which will learn you how to send e-mails from Microsoft Outlook to SharePoint.

Until then you can test the product that we made to accomplish this in real life.

Try it for free, goto www.spapi.com and the Downloads section.

The tutorial will start on the 16th of october, next week.

Posted: 09-13-2009 11:34 by diaz.net with no comments

Beta testers for Outlook to SharePoint application is wanted!

Last week me and my new work announced the first Beta of MailDropper for SharePoint. We are now looking for beta testers all around the world from single users to large corporate organizations.

We will provide you with the software, instructions and a testpaper that you will have to fill out (Only one page!).

So mail me at andreas@bestpromotion.se or ak@gkviby.com and I will contact you and send you the software.

For thoose of you that do not know what MailDropper do take a look at www.spapi.com for more information and screenshots.

Posted: 09-12-2009 22:25 by diaz.net with no comments

SharePointCommunity nere idag!

swedish

Jag hade missat att förlänga abonnemanget på eget domän på NING Networks och idag slutade det att fungera.

Men nu är det förlängt ett tag till så nu hoppas jag att den nya plattformen kommer till liv under oktober.

Jag ber om ursäkt!

Posted: 09-12-2009 22:20 by diaz.net with no comments

Filed under:

MailDropper for SharePoint just hit the planet!

MailDropper for SharePoint is finally out for testing on the market and the interest is very high. With the help of MailDropper for SharePoint it will be easy to send one or more e-mails from Microsoft Outlook into SharePoint.

create.your.own.settings.in.maildropper MailDropper allows you to configure lists you want to send emails to and save these settings as favorites.

MailDropper also takes the entire

Posted: 09-10-2009 23:40 by diaz.net with no comments

.NET consultant looking for work

Well it was not one of the posts I planned to write when the new year bells told everyone it’s 2009! But here I am, just got canned due to lack of work. Love the company Human Data and wish them my best in the future and maybe our roads will cross once again sometime in the future.

I have never got canned before in my life so this is new to me. I have always made a choice to move on, to upgrade my CV or just try to make the world a better place :)

When you get canned you must suddenly plan for your future between 8 and 5 working days, strange feeling huh?

I just realized that I am made to carry out smaller and shorter projects within ASP.NET, ASP.NET MVC, C#, VB.NET, SQL Server or other technologies like Windows Forms development or even development of a new application for Windows Mobile. I am fast and accurate in those kind of projects but I am not made for long term projects. So anything between 20 and 150 is my kind of case.

My knowledge is deep and wide, I have been developing apps for the Microsoft world ever since VB got released on diskettes a while ago :) I have spent my whole life with VB and speak and write VB and VB.NET fluently.

I now work almost fluent in both C# and VB.NET and have focused a couple of years now on SharePoint development. Just started to make some stuff in ASP.NET MVC and with my Ruby on Rails background I can tell you folks, it rocks!

If you need a consultant anywhere in the world, send me an e-mail (ak@gkviby.com) and you will get my CV back and my pricelist.

I take on jobs from the 1st of august 2009.

Posted: 06-23-2009 16:21 by diaz.net with no comments

Missa inte årets SEF!

SharePoint och Exchange forum, seforum! Missa inte årets upplaga som både innehåller nördspår och vanliga spår.

Lär mer på www.seforum.se!

Passa på att anmäla er innan den sista juni och spara pengar.

image

Posted: 06-23-2009 16:02 by diaz.net with no comments

Filed under:

Use SharedView to collaborate in smaller teams

SharedView is another small and neat freeware from Microsoft. It allows you to start a session with maximum of 15 attenders and share what window you like. You can even upload handouts to the people.

My first idea is ofcourse to start using this for the work with SharePoint Community Sweden and also to be able to arrange online classes. I think this is a great tool and I hope that we will see to cool testing of here soon.

image

http://connect.microsoft.com/site/sitehome.aspx?SiteID=94

Posted: 05-15-2009 8:04 by diaz.net with no comments

Running JavaScript and CSS inside your Web Parts

I have been struggling with this task for a while in my development projects. The task is how to include JavaScript and CSS files in your Web Part project. There are tons of quick and dirty solutions but I decided to find a smoother way to include them.

This is my solution.

SharePointNerd - Andreas Kviby - SharePoint - Blog

I created a new class in Visual Studio 2008 and found these two excellent functions. RegisterCSS and RegisterScript. It wasn’t invented by me but I still feel I have to share this because I know that a lot of people find this hard to do.

image

So from my Web Part code I just call the RegisterCSS and send in the path to the CSS file and the this object to make sure the code gets added to the right Web Part.

When I run this code inside any Web Part project it will add and put the CSS and the JavaScript at the right place and it all works like a charm.

If you would like to extend this you should ofcourse make it a Web Part Editable setting where to find the CSS and the JavaScript and my recommendation is to use a standard Document Library to store them in and then let the user choose Document Library and then the particular file. Neat!

Thanks for this time!

Posted: 05-10-2009 11:06 by diaz.net with no comments

SharePoint Journal gratis!

swedishflag

Tillsammans med Understanding SharePoint Journal har jag glädjen att ge bort senaste eller valfritt nummer till 10 medlemmar på SharePoint Community Sverige.

I del tre av SharePoint Journal går författaren igenom den egentillverkade fälttypen SPTags. Det är till och med 90 minuters video med.

Helt hysteriskt bra material för den inbitne!

För att vinna en gratis kod värd 14,95 USD skickar du en motivering på Engelska varför just du behöver SharePoint Journal och en kort text varför du tycker SharePoint Community är en bra plats. Skicka detta inklusive länken till din medlemssida på communityportalen.

För till kvarn gäller så skriv på och mejla mig andreas[at]humandata[.]se.

Posted: 04-23-2009 11:18 by diaz.net with no comments

Filed under:

I am developing you a free Sharepoint product!

So here is my challenge for all you SharePoint nerds out there.

I want to get your suggestions on SharePoint products missing or that be done better than the existing ones.

It can be webparts, features, custom fields or whatever. Send all your crazy and wild ideas to me at my workmail below and you could win your product.

I will choose one of them each month and develop it and give it away for free as a ready to install SharePoint product to the one who tipped me.

I do this because I need to be challenged and I trust all you out there have ideas you would like to see alive.

andreas[at]humandata[.]se

See you soon!

Posted: 04-21-2009 23:34 by diaz.net with 1 comment(s)

Filed under: ,

SPTags explained on 107 pages

Have you ever thought about custom fields in SharePoint? Then here is your ride to success. Everything explained in details and with videos as well. You will even get to know how to present the results in various ways in webparts.

It is just amazing that you actually buy a complete class, education or you can even call it a small book for only 14,95 USD per issue.

I has my doubts in the beginning about buying material this way but now I am more than convinced. I am thrilled!

Issue 1 and 2 was great and now Issue 3 is like past issues on steroids!

Grab your own issue right now, right here!

image

Understanding SharePoint Journal Issue 3 – SPTags explained!

Posted: 04-21-2009 23:16 by diaz.net with no comments

Remote Document Library Viewer

So it is finally time for some serious testing of my new WebPart for SharePoint. Made for both WSS and MOSS Document Libraries and now with even more functionality missing in standard SharePoint.

image

What you see in the imabe above is a Document Library displayed with my DocPart WebPart. The Document Library is located in the the Root Site and named Docs. My Webpart is displaying that Document Library on a subsite with no problems.

It even displays the remote document library’s Views and when you select a View it will also show you thoose columns marked for display in that particular view.

All columns supports ordering.

image

You can also see it supports icons for document types and even folders. What makes my WebPart different from the built-in webpart is when you click a folder.

image

When clicked you will see folders and items inside the clicked folder as in the image above. BUT! You also see the Up… Icon which will make it easy to browse your document libraries folders.

 You can display Document Libraries from any Site within the same Web Application!

Want to testdrive this app? Want to participate the betaprogram? Send an e-mail to me at andreas[at]humandata[.]se.

Posted: 04-17-2009 11:19 by diaz.net with 1 comment(s)

SharePoint 14 goes SharePoint 2010

It’s official. Today Microsoft announced that the official name of SharePoint “14” is SharePoint 2010.

Read more

Posted: 04-16-2009 3:07 by diaz.net with no comments

Filed under:

More Posts Next page »