source:
http://www.aspnetcafe.com/post/2007/12/Scheduled-task-in-middle-trust-enviroment.aspx
Create a vbs file with the creation of a xmlthttp request:
Call RunIt()
Sub RunIt()
'Let the script to finish on an error.
On Error Resume Next
'Declare variables
Dim RequestObj
Dim URL
Set RequestObj = CreateObject("Microsoft.XMLHTTP")
'Request URL...
URL = "http://www.URL.com/jobsendmail/default.aspx"
'Open the HTTP request and pass the URL to the objRequest object
RequestObj.open "POST", URL , false
'Send the HTML Request
RequestObj.Send
'Set the object to nothing
Set RequestObj = Nothing
End Sub
'End of file
Get the directory of the vbs on the server using aspx page:
Response.Write(Server.MapPath("schedule.vbs"))
On the scheduler task use the path returned and define the schedule to run
Simple and easy
23/06/09
30/10/08
Instr + Mid using Javascript
<script type="text/javascript">
function Mid(str, start, len) {
// Make sure start and len are within proper bounds
if (start < 0 || len < 0) return "";
var iEnd, iLen = String(str).length;
if (start + len > iLen)
iEnd = iLen;
else
iEnd = start + len;
return String(str).substring(start,iEnd);
}
function InStr(strSearch, charSearchFor) {
for (i=0; i < strSearch.length; i++)
{
if (charSearchFor == Mid(strSearch, i, 1))
{
return i;
}
}
return -1;
}
</script>
29/07/08
Paging Using SQL Server SP
create PROC P_GET_PAGE
(
@p_page int,
@p_page_size int
)
as
begin
set nocount on
declare @p_total_rows_num int
declare @p_first_selecting_row_num int
declare @p_first_selecting_row_id int
select @p_total_rows_num = count(IDFIELD) from TableName
select @p_first_selecting_row_num = (@p_page - 1) * @p_page_size + 1
if (@p_first_selecting_row_num <= @p_total_rows_num)
begin
set rowcount @p_first_selecting_row_num
select @p_first_selecting_row_id = IDFIELD
from TableName
order by 1
set rowcount @p_page_size
select * from TableName
where IDFIELD >= @p_first_selecting_row_id
order by 1
end
set nocount off
end
/* exe SP numpage,numitems*/
exec P_GET_PAGE 1, 4
Tags:
SQL
23/07/08
Create Public Var In UserControl
How to call it
on the user control just define:
C#
VB.NET
on the user control just define:
C#
string strGroupClassID;
VB.NET
Public strGroupClassID As String
Tags:
ASP.NET,
USERCONTROL
Abstract Class to Encapsulate Session Variables
C#
VB.NET
public class Cls_Vars_RC {
private const string UserIdKey = "SID";
private static HttpSessionState Session {
get {
return HttpContext.Current.Session;
}
}
public static bool Exists {
get {
return !(Session == null);
}
}
public static string UserId {
get {
return Session(UserIdKey);
// Return
}
set {
Session(UserIdKey) = value;
}
}
public void CriaSessao(string ID) {
Current.Session("SLogin") = true;
Current.Session("SID") = ID;
}
public void ApagaSessao() {
Current.Session("SLogin") = false;
Current.Session("SID") = "";
}
bool CHKSession() {
if ((Current.Session("SLogin") == true)) {
return true;
}
else {
return false;
}
}
}
VB.NET
Public Class Cls_Vars_RC
Private Const UserIdKey As String = "SID"
Public Sub CriaSessao(ByVal ID As String)
Current.Session("SLogin") = True
Current.Session("SID") = ID
End Sub
Public Sub ApagaSessao()
Current.Session("SLogin") = false
Current.Session("SID") = ""
End Sub
Function CHKSession() As Boolean
If Current.Session("SLogin") = True Then
Return True
Else
Return False
End If
End Function
Private Shared ReadOnly Property Session() As HttpSessionState
Get
Return HttpContext.Current.Session
End Get
End Property
Public Shared ReadOnly Property Exists() As Boolean
Get
Return Not Session Is Nothing
End Get
End Property
Public Shared Property UserId() As String
Get
Return Session(UserIdKey)
' Return
End Get
Set(ByVal value As String)
Session(UserIdKey) = value
End Set
End Property
End Class
Tags:
ASP.NET
Retrieve column from SQL Server Table
Can Use
or
select column_name, data_type, character_maximum_length from information_schema.columnswhere table_name = 'myTable'
or
DECLARE @tablename varchar(100)
SET @tablename = N'myTable'
SELECTclmns.name AS [Name],usrt.name AS [DataType],ISNULL(baset.name, N'') AS [SystemType],CAST(CASE WHEN baset.name IN (N'nchar', N'nvarchar') AND clmns.max_length <> -1 THEN
clmns.max_length/2 ELSE clmns.max_length END AS int) AS [Length],CAST(clmns.precision AS int) AS [NumericPrecision]
FROM
sys.tables AS tblINNER JOIN sys.all_columns AS clmns ON clmns.object_id=tbl.object_id
LEFT OUTER JOIN sys.types AS usrt ON usrt.user_type_id = clmns.user_type_idLEFT OUTER JOIN sys.types AS baset ON baset.user_type_id = clmns.system_type_id and baset.user_type_id = baset.system_type_id
WHERE(tbl.name=@tablename and SCHEMA_NAME(tbl.schema_id)=N'dbo')
ORDER BYclmns.column_id ASC
I've tried with SQL Server 2005 and 2000 and worked well
Subscrever:
Mensagens (Atom)