|
Navigation
Categories
Entries by Month
| October, 2008 (1) |
| September, 2008 (1) |
| July, 2008 (4) |
| June, 2008 (6) |
| May, 2008 (2) |
| March, 2008 (5) |
| December, 2007 (1) |
| October, 2007 (1) |
| September, 2007 (2) |
| May, 2007 (1) |
| April, 2007 (5) |
| October, 2006 (1) |
| July, 2006 (2) |
| June, 2006 (6) |
| January, 2006 (2) |
| December, 2005 (6) |
| November, 2005 (9) |
| October, 2005 (9) |
| September, 2005 (3) |
| August, 2005 (11) |
| July, 2005 (20) |
| June, 2005 (3) |
| May, 2005 (5) |
| April, 2005 (5) |
| March, 2005 (5) |
| February, 2005 (5) |
| January, 2005 (13) |
| December, 2004 (10) |
| November, 2004 (6) |
| October, 2004 (2) |
| September, 2004 (7) |
| August, 2004 (8) |
| July, 2004 (8) |
| June, 2004 (4) |
| May, 2004 (13) |
| April, 2004 (14) |
| March, 2004 (33) |
| February, 2004 (1) |
| May, 2003 (6) |
| April, 2003 (5) |
| March, 2003 (4) |
| February, 2003 (1) |
| January, 2003 (6) |
|
|
|
 Tuesday, August 16, 2005
 Sunday, August 14, 2005
I had to move an extranet application, including the databases, to a new server. The application has just over 300 sites, so of course I had to write code! There is a lot of file copies, but the script does include one interesting piece: creating a database on a server and creating an empty database.
The solution was written in VBScript and runs on a Windows XP machine. The script uses SQL-DMO to perform the database admin steps. I am including the script below as an example.
Now, I am sure that many of you will have an opinion about the code. That is fine. But do not flame about database best practices -- I am simply moving an existing application with specific requirements. And do not flame about the hungarian notation -- VB Script does not have strong typing and the entire script is almost 400 lines. Feel free to flame anything else. 
Sub CreateDB(DBServer, SiteName) Dim oDBDataFile, sDataPath, oDBLogFile, sLogPath Dim oSvr, oDB
Set oSvr = CreateObject("SQLDMO.SQLServer") oSvr.Connect DBServer, "user", "password" ' Could use WinNT login
Set oDB = CreateObject("SQLDMO.Database") Set oDBDataFile = CreateObject("SQLDMO.DBFile") Set oDBLogFile = CreateObject("SQLDMO.LogFile")
'Set new database name oDB.Name = SiteName
'Define the PRIMARY data file. oDBDataFile.Name = SiteName sDataPath = oSvr.Registry.SQLDataRoot & "\DATA\" & SiteName & ".mdf" oDBDataFile.PhysicalName = sDataPath oDBDataFile.PrimaryFile = True oDBDataFile.Size = 2 'Set initial size (optional)
oDBDataFile.FileGrowthType = SQLDMOGrowth_MB 'fixed size - other options available oDBDataFile.FileGrowth = 1
'Add the DBFile object oDB.FileGroups("PRIMARY").DBFiles.Add oDBDataFile
'Define the database transaction log. oDBLogFile.Name = SiteName & "Log" sLogPath = oSvr.Registry.SQLDataRoot & "\DATA\" & oDBLogFile.Name & ".ldf" oDBLogFile.PhysicalName = sLogPath oDBLogFile.Size = 2 oDB.TransactionLog.LogFiles.Add oDBLogFile
'Create the database as defined. oSvr.Databases.Add oDB 'Add a user to the database Set oUser = CreateObject("SQLDMO.User") oUser.Login = "ExNet" oUser.Role = "db_owner" ' Make sure this is appropriate for you! oDB.Users.Add(oUser)
' Now, build the schema from the file of SQL statements Const ForReading = 1, ForWriting = 2 Dim oFSO, oFile, sFile, sCmdBatch SET oFSO = CreateObject("Scripting.FileSystemObject")
sFile = "C:\Visual Studio Projects\ExNetMove\CreateDatabase2_05.sql" SET oFile = oFSO.OpenTextFile(sFile, ForReading)
sCmdBatch = oFile.ReadAll oDB.ExecuteImmediate sCmdBatch, SQLDMOExec_ContinueOnError
oFile.Close
End Sub
 Thursday, August 11, 2005
I don't have the time for a full review, but the book Building ASP.Net Server Controls by Dale Michalk and Rob Cameron has been very helpful for a long time.
If you are interested in writing server controls (and remember, Web Parts are server controls) this book is for you. The authors start out with very basic "write" statements, but they progress into a sophisticated control -- one that includes templates, CSS styling and data binding.
 Wednesday, August 03, 2005
 Tuesday, August 02, 2005
 Sunday, July 31, 2005
 Saturday, July 23, 2005
Update: The Image Upload Web Part has been updated.
Heather Solomon blogged about end-user-focused web parts. (Be sure to look at the comments for links to many others.) All are very valid points.
I have a small but helpful contribution: The ImageUpload Web Part.
On a WSS Team site, the default template has an Image Web Part that displays the Windows Logo. I have never seen this logo on a production site. To change the image is easy enough for users familiar with the Web Part page model: Open the tool pane and change the location of the image. This is where it gets difficult for end-users.
What if the image is on the end-user's computer? Most likely, they email the file to the webmaster/developer. It is then uploaded to web server and the URL emailed back to the user. (Or the webmaster/developer is updating the web part.) More industrious users will post the image to a photo gallery. Some will even determine the URL. But there is an easier way.
The ImageUpload Web Part displays a form with a file upload input box. The end user can click the browse button and select the image. The web part stores the image in a document library and automatically remembers the location (URL) and renders the <IMG> tag correctly.
Download the CAB file and source code.
The web part requires a setting in web.config with the location to store the images. And, the end user must have permission to store items in that library. (This second restriction could be alleviated using impersonation techniques from Todd Bleeker or Victor Vogelpoel or Jay Nathan.)
 Wednesday, July 20, 2005
|
|
Search

Further Reading...
Powered by: newtelligence dasBlog 2.2.8279.16125
The opinions expressed herein are my own personal opinions and do
not represent my employer's view in anyway.
© Copyright 2008, Paul Schaeflein
E-mail
|