Archive

Archive for the ‘Snippets’ Category

performance

Tuesday, 18 August, 2009 Baur Leave a comment
DECLARE
 l_start NUMBER;
 l_end   NUMBER;
BEGIN
 ...
 l_start := dbms_utility.get_time;
 ...
 l_end   := round((dbms_utility.get_time - l_start) / 100, 2);
 dbms_output.put_line(l_end || ' seconds...');
END;
Categories: PL/SQL, Snippets Tags: ,

(PL\SQL) How to get MAX(num)+DISTINCT str

Tuesday, 18 August, 2009 Baur 2 comments
CLEAR;
with t as
 (
 select '11' num, 'string1' str, '1' DATA from dual union all
 select '12' num, 'string1' str, '3' DATA from dual union all
 select '15' num, 'string1' str, '3' DATA from dual union all
 select '25' num, 'string2' str, '10' DATA from dual union all
 select '26' num, 'string2' str, '2' DATA from dual union all
 SELECT '29' num, 'string2' str, '4' DATA from dual
 )
SELECT * FROM t
WHERE num IN (SELECT MAX(num) FROM t tt WHERE t.str = tt.str);
Categories: PL/SQL, Snippets Tags: ,

Index info oracle

Tuesday, 20 January, 2009 Baur Leave a comment
SELECT a.index_name,  b.column_name,
           a.index_type, a.table_name
  FROM USER_INDEXES a, USER_IND_COLUMNS b
 WHERE a.index_name = b.index_name
       AND a.table_name = upper('tDocument');
Categories: Oracle, Snippets Tags: ,

Global Variable 2nd method

Thursday, 15 May, 2008 Baur 3 comments

App_Code\GData.cs
using System;
using System.Data;
...
public class UserInfo
{
private static string pin;
public static string Pin
{
get { return pin; }
set { pin = value; }
}
private static string fio;
public static string Fio
{
get { return fio; }
set { fio = value; }
}
}
public class QData
{
...
public class GData
{
public static void SetUserInfoPIN(string pin)
{
UserInfo.Pin = pin;
}
public static string GetUserInfoPIN()
{
return UserInfo.Pin;
}
...
}

Read more…

Read typed file – pascal

Wednesday, 7 May, 2008 Baur 1 comment

File structure in C++

typedef struct TAGRECORD
{
char DeviceName[50]; // Имяприбора
char TagName[10]; // Имяпараметра
char TagValue[50]; // Значение
time_t TagTime; // Время записи
int TagChannel; // Канал
int TagInfo; // 0 - info, 1 - control
} TAGRECORD,*LPTAGRECORD;

Read it with Pascal?

Solution >>>
Read more…

Categories: Delphi, Pascal Tags: , ,

Cool CSS templates

Monday, 28 April, 2008 Baur 8 comments
Categories: CSS, HTML Tags: , ,

[C#] Using the switch case Statement

Saturday, 26 April, 2008 Baur 1 comment

The switch statement chooses flow of control based on the evaluation of a
numeric or string comparison.The switch statement does not allow control to fall
through to the next case as in C/C++ unless the case statement is followed
immediately by another case statement. In other words, you must use a break statement
with every case statement.You can also use a goto statement, although most
programmers frown on using them. Here are two examples:

int j = 0;
int i = 1;
switch (i)
{
case 1:j = 7;break;
case 2:
case 3:j = 22;break;
default:j = 33; break;
}

string lastName = “”;
string text = “fred”;
switch ( text )
{
case “fred”:lastName = “Flinstone”;break;
case “barney”:lastName = “Rubble”;break;
default:lastName = “Slate”;break;
}

Categories: C# Tags: ,

Getting Visitor’s IP Address and Server’s IP Address

Thursday, 24 April, 2008 Baur 3 comments

Getting Visitors IP Address:

There are two ways, either by using:
HttpContext.Current.Request.UserHostAddress;
or
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

The Following Line will get the IP Address of the machine instead of Proxy’s IP

HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

Getting Server’s IP address:

string strHostName = Dns.GetHostName ();
IPHostEntry ipEntry = Dns.GetHostByName (strHostName);
IPAddress [ ] addr = ipEntry.AddressList;
for(int i=0;i< addr.Length;i++)
{
lblServerIP.Text=lblServerIP.Text+"The Server IP address is"+addr[i].ToString()+"\n";
}

Categories: ASP.NET 2.0, C# Tags: ,

Fill DropDownLists

Thursday, 24 April, 2008 Baur Leave a comment

void FillDropDownLists()
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ASPGConnectionString"].ConnectionString);
SqlCommand commGetDept = new SqlCommand("select id, dept from s_dept where id in (select dept from s_users) order by dept", conn);
try
{
conn.Open();
SqlDataReader res = commGetDept.ExecuteReader();
ListDepts.DataTextField = "dept";
ListDepts.DataValueField = "id";
ListDepts.DataSource = res;
ListDepts.DataBind();
ListDepts.Items.Insert(0, "Все");
res.Close();
}
catch (SqlException sqlex)
{
//ErrMess.Text = sqlex.Message;
return;
}
catch
{
return;
}
finally
{
if (conn.State != ConnectionState.Closed) conn.Close();
}
}

Get data from web.config

Thursday, 24 April, 2008 Baur 1 comment

Any data
——————————————————
store:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="admins" value="esetov_b, lobanov_v"/>
</appSettings>
...

get:
string admins = ConfigurationManager.AppSettings["Admins"];

Connection String
——————————————————
store
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ASPGConnectionString" connectionString="Data Source=DS;Initial Catalog=basename;Persist Security Info=True;User ID=user;Password=psw"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
...

get
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings["ASPGConnectionString"].ConnectionString);