Joseph Michael Pesch
VP Programming

ASP.Net JavaScript Include References by Root Path (~/) Equivelant

by 27. April 2009 20:42

You cannot add a runat="Server" attribute to a <script> tag (otherwise it will actually run the script server side).  Without this attribute the script needs to have a relative path vs. a root path (e.g. ../../scripts/script.js vs. ~/scripts/script.js).  To overcome this limitation you can add stylesheet and/or script references using the following type of code to a Page_Load event on an ASP.Net web page:

Page.Header.Controls.Add(newLiteralControl(@"<link href='" + ResolveUrl("~/css/MainStyle.css") + "' rel='stylesheet' type='text/css' />\r\n"));

Page.Header.Controls.Add(newLiteralControl(@"<script src='" + ResolveUrl("~/JQuery/jquery-1.3.2.min.js") + "' type='text/javascript'></script>\r\n"));

 

 

Tags: ,

ASP.Net

Linq to SQL Schema Refresh (SQLMetal.exe & SQLMetalOSUI)

by 26. April 2009 20:13

SQLMetal.exe is a command line tool that will build Linq to SQL *.dbml code files. http://msdn.microsoft.com/en-us/library/bb386987.aspx (file location: %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bin\SQLMetal.exe)

SQLMetalOSUI (Open Source User Interface) is an open source UI for running SQLMetal.exe http://www.codeplex.com/sqlmetalosui

SQLMetal.exe Parameters:

Microsoft (R) Database Mapping Generator 2008 version 1.00.30729
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.
SqlMetal [options] [<input file>]
Generates code and mapping for the LINQ to SQL component of the .NET framework. SqlMetal can:
- Generate source code and mapping attributes or a mapping file from a database.
- Generate an intermediate dbml file for customization from the database.
- Generate code and mapping attributes or mapping file from a dbml file.
Options:
/server:<name> Database server name.
/database:<name> Database catalog on server.
/user:<name> Login user ID (default: use Windows Authentication).
/password:<password> Login password (default: use Windows Authentication).
/conn:<connection string> Database connection string. Cannot be used with /server, /database, /user or /password options.
/timeout:<seconds> Timeout value to use when SqlMetal accesses the database (default: 0 which means infinite).
/views Extract database views.
/functions Extract database functions.
/sprocs Extract stored procedures.
/dbml[:file] Output as dbml. Cannot be used with /map option.
/code[:file] Output as source code. Cannot be used with /dbml option.
/map[:file] Generate mapping file, not attributes. Cannot be used with /dbml option.
/language:<language> Language for source code: VB or C# (default: derived from extension on code file name).
/namespace:<name> Namespace of generated code (default: no namespace).
/context:<type> Name of data context class (default: derived from database name).
/entitybase:<type> Base class of entity classes in the generated code (default: entities have no base class).
/pluralize Automatically pluralize or singularize class and member names using English language rules.
/serialization:<option> Generate serializable classes: None or Unidirectional (default: None).
/provider:<type> Provider type: SQLCompact, SQL2000, SQL2005, or SQL2008. (default: provider is determined at run time).
<input file> May be a SqlExpress mdf file, a SqlCE sdf file, or a dbml intermediate file.
Create code from SqlServer:
SqlMetal /server:myserver /database:northwind /code:nwind.cs /namespace:nwind
Generate intermediate dbml file from SqlServer:
SqlMetal /server:myserver /database:northwind /dbml:northwind.dbml /namespace:nwind
Generate code with external mapping from dbml:
SqlMetal /code:nwind.cs /map:nwind.map northwind.dbml
Generate dbml from a SqlCE sdf file:
SqlMetal /dbml:northwind.dbml northwind.sdf
Generate dbml from SqlExpress local server:
SqlMetal /server:.\sqlexpress /database:northwind /dbml:northwind.dbml
Generate dbml by using a connection string in the command line:
SqlMetal /conn:"server='myserver'; database='northwind'" /dbml:northwind.dbml

Tags: ,

LINQ to SQL

SSRS Default Beg and End Dates to First and Last Day of Current Month

by 7. April 2009 15:57

BegDate: =CDate("01/" & Month(Now) & "/" & Year(Now))

EndDate: =DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, Parameters!BegDate.Value))

Tags: ,

SSRS

SQL Server 2005 Pivot Table

by 7. April 2009 14:21

declare @example table

(

  GroupID integer

, ItemID  integer

, Value1  varchar(10)

, Value2  varchar(10)

)

insertinto @example

select 1, 1,'First',   'James'     union all

select 1, 2,'Last',    'Smith'     union all

select 1, 3,'Country','UK'        union all

select 1, 4,'Hobby',   'Rugby'     union all

select 2, 1,'First',   'Alan'      union all

select 2, 2,'Last',    'Jackson'   union all

select 2, 3,'Country','USA'       union all

select 2, 4,'Hobby',   'Fishing'

--select * from @example

 

select

  GroupID

,max([First])+' '+max([Last])as [Name]

,max([Country])as Country

,max([Hobby])as Hobby

from

  @example

pivot

(

  max(Value2)for Value1 in([First], [Last], [Country], [Hobby])

) pvt

groupby GroupID

 

/*

GroupID     Name         Country Hobby

----------- ------------ ------- ----------

1               James Smith   UK        Rugby

2               Alan Jackson USA       Fishing

*/

 

Tags: ,

SQL Server