Find it with the following sql statement on master db.
use master
select name, dbid
from sysdatabases
order by name
Thursday, June 02, 2005
do you need the Database ID to trace your DB?
at
5:17 PM
0
comments
Posted by
roni schuetz
Thursday, May 26, 2005
Wednesday, May 25, 2005
HowTo create Virtual Directiories in IIS with vbs
just take the following vbs code, adapt it and save it in a *.vbs file.
//////////////////////////////////////////////////////////////////
On error resume next
'
' Running as a VBS
'
Script = True
Source = GetPath
WebRoot = "c:\inetpub\wwwroot"
set fso = CreateObject("Scripting.FileSystemObject")
for each site in fso.GetFolder(Source).SubFolders
FolderName = fso.GetFileName(Site.Path)
if lcase(FolderName) <> "solution" then
ReinstallWebApplication FolderName
CheckError
end if
next
CheckError
Function Share(Path, Name)
Output "Sharing " & Path
'dim objServices As SWbemServices
Set objServices = GetObject _
("WinMgmts:{impersonationLevel=impersonate}!/root/cimv2")
'************************ Create the new share *********************
Set objShare = objServices.Get("Win32_Share")
Set objInParam = objShare.Methods_("Create").InParameters.SpawnInstance_()
objInParam.Properties_.Item("Description") = ""
objInParam.Properties_.Item("Name") = Name
objInParam.Properties_.Item("Path") = Path
objInParam.Properties_.Item("Type") = 0
'************************ Execute the method **********************
Set ObjOutParams = objShare.ExecMethod_("Create", objInParam)
If ObjOutParams.ReturnValue <> 0 And ObjOutParams.ReturnValue <> 22 Then
Beep
Output "***Unable to create share, return value was : " _
& "objOutParams.ReturnValue"
End If
End Function
'
' The following compatability functions allow this script to function in VB
' or as a VBS file.
'
Sub Output(s)
If Script Then
WScript.echo s
Else
Debug.Print s
End If
End Sub
Function GetPath()
If Script Then
GetPath = Left(WScript.scriptfullname, InStrRev(WScript.scriptfullname, "\") - 1)
Else
GetPath = App.Path
End If
End Function
Function Run(s)
If Script Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run s, ,true
Else
Shell s, vbNormalFocus
End If
End Function
Sub CheckError()
if Err.Number then
msgbox err.number & ":" & err.source & ":" & err.description
if script then
wscript.quit
else
stop
end if
end if
end sub
Sub StopService(ServiceName)
Set objServices = GetObject _
("WinMgmts:{impersonationLevel=impersonate}")
Set services = objServices.InstancesOf("Win32_Service")
For Each s In services
If s.DisplayName = ServiceName Then
s.ChangeStartMode ("Manual")
s.StopService
End If
Next
end sub
Sub DeleteGPO(nc, DisplayName)
'Dim Policies As IADsContainer
Set Policies = GetObject("LDAP://CN=Policies,CN=System," & nc)
'Dim Policy
For Each Policy In Policies
If Policy.DisplayName = DisplayName Then
'Dim c As IADsContainer
Set c = Policy
RecursiveDelete c
Policies.Delete Policy.Class, Policy.Name
Exit For
End If
Next
End Sub
Sub RecursiveDelete(c)
'Dim subc As IADsContainer
For Each subc In c
RecursiveDelete subc
Next
For Each subc In c
c.Delete subc.Class, "CN=" & subc.cn
Next
End Sub
Sub Uninstall(PartialName)
Set objServices = GetObject _
("WinMgmts:{impersonationLevel=impersonate}!/root/cimv2")
Set Products = objServices.InstancesOf("Win32_Product")
For Each product In Products
If instr(product.Name,PartialName) > 0 Then
output "Uninstalling " & product.name
product.uninstall
End If
Next
end sub
Sub ReinstallWebApplication(AppName)
UninstallWebApplication AppName
InstallWebApplication(AppName)
end Sub
sub UninstallWebApplication(AppName)
set fso = createobject("scripting.filesystemobject")
on error resume next
Set DirObj = GetObject("IIS://LocalHost/W3SVC/1/ROOT/" & AppName)
DirObj.AppDelete
on error goto 0
DeleteFolder WebRoot & "\" & AppName
end sub
sub InstallWebApplication (AppName)
set fso = createobject("scripting.filesystemobject")
output "Copying : " & Source & "\" & AppName & " to " & WebRoot & "\" & AppName
fso.CopyFolder Source & "\" & AppName, WebRoot & "\" & AppName
checkerror
Dim DirObj
Const INPROC = True
Const OUTPROC = False
output "Creating Web Application for IIS://LocalHost/W3SVC/1/ROOT/" & AppName
Set DirObj = GetObject("IIS://LocalHost/W3SVC/1/ROOT")
on error resume next
DirObj.delete "IIsWebVirtualDir", AppName
on error goto 0
set mywd = DirObj.Create ("IIsWebVirtualDir", AppName)
mywd.setinfo
mywd.AppCreate true
mywd.setinfo
run """c:\program files\common files\microsoft shared\web server extensions\40\bin\fpsrvadm.exe"" -o install -p 80 -w /" & AppName
run """c:\program files\common files\microsoft shared\web server extensions\40\bin\fpsrvadm.exe"" -o check -p 80 -w /" & AppName
end sub
function MyDocuments()
set shell = createobject("WScript.Shell")
MyDocuments = shell.SpecialFolders("MyDocuments")
end function
sub DeleteFile(FileName)
set fso = createobject("scripting.filesystemobject")
if fso.fileexists(filename) then
output "Deleting : " & filename
fso.deletefile filename, true
end if
end sub
sub DeleteFolder(FolderName)
set fso = createobject("scripting.filesystemobject")
if fso.FolderExists(Foldername) then
output "Deleting : " & Foldername
fso.deleteFolder Foldername, true
end if
end sub
at
3:29 PM
2
comments
Posted by
roni schuetz
Retriving Data from AssemblyInfo.cs
How to get data from the AssemblyInfo.cs can be made by a helper class inside the Assembly file:
Class1.cs
public class MyWinForm:System.Windows.Forms.Form
{
[STAThread]
static void Main()
{
Application.Run(new MyWinForm());
}
// its contains much more then the Main method but for this sample its enough.
}
AssemblyInfo.cs
// that part is generated auto. by visual studio
using System;
using System.Reflection;
[assembly: AssemblyTitle("Your Custom Assembly Title")]
[assembly: AssemblyDescription("Some information about your Assembly")]
[assembly: AssemblyCompany("Your Company Name")]
[assembly: AssemblyProduct("Your Product Name")]
[assembly: AssemblyCopyright("Who has the copyright")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyVersion("1.0.0.0")]
#region Helper class
// Your generated class does not contain the follwoing part.
public class AssemblyInfo
{
// Used by Helper Functions to access information from Assembly Attributes
private Type myType;
public AssemblyInfo()
{
myType = typeof(MyWinForm);
}
public string AsmName
{
get {return myType.Assembly.GetName().Name.ToString();}
}
public string AsmFQName
{
get {return myType.Assembly.GetName().FullName.ToString();}
}
public string CodeBase
{
get {return myType.Assembly.CodeBase;}
}
public string Copyright
{
get {
Type at = typeof(AssemblyCopyrightAttribute);
object[] r = myType.Assembly.GetCustomAttributes(at, false);
AssemblyCopyrightAttribute ct = (AssemblyCopyrightAttribute) r[0];
return ct.Copyright;
}
}
public string Company
{
get
{
Type at = typeof(AssemblyCompanyAttribute);
object[] r = myType.Assembly.GetCustomAttributes(at, false);
AssemblyCompanyAttribute ct = (AssemblyCompanyAttribute) r[0];
return ct.Company;
}
}
public string Description
{
get
{
Type at = typeof(AssemblyDescriptionAttribute);
object[] r = myType.Assembly.GetCustomAttributes(at, false);
AssemblyDescriptionAttribute da = (AssemblyDescriptionAttribute) r[0];
return da.Description;
}
}
public string Product
{
get
{
Type at = typeof(AssemblyProductAttribute);
object[] r = myType.Assembly.GetCustomAttributes(at, false);
AssemblyProductAttribute pt = (AssemblyProductAttribute) r[0];
return pt.Product;
}
}
public string Title
{
get
{
Type at = typeof(AssemblyTitleAttribute);
object[] r = myType.Assembly.GetCustomAttributes(at, false);
AssemblyTitleAttribute ta = (AssemblyTitleAttribute) r[0];
return ta.Title;
}
}
public string Version
{
get {return myType.Assembly.GetName().Version.ToString();}
}
}
#endregion
Now back to the "Class1.cs" where we see how to use it:
public class MyWinForm:System.Windows.Forms.Form
{
public void SetAnAssemblyInfoToControlOfYourChoice()
{
AssemblyInfo ainfo = new AssemblyInfo();
string title = ainfo.Title;
this.YourControlInstance.Text = string.Format("{0} ...", ainfo.Title);
}
}
at
12:48 PM
0
comments
Posted by
roni schuetz