public void Log(string Message, TextWriter w)
{
w.Write("\r\nLog Entry: ");
w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString());
w.WriteLine(" :");
w.WriteLine(" :{0}", Message);
w.WriteLine("-------------------------------");
}
public void DumpLog(StreamReader r)
{
string line;
while ((line = r.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
using (StreamWriter w = File.AppendText(SererLogFileMapPath + "log.txt"))
{
Log(ex.Message, w);
}
using (StreamReader tr = File.OpenText(SererLogFileMapPath + "log.txt"))
{
DumpLog(tr);
}
Thứ Sáu, 26 tháng 9, 2014
Thứ Năm, 18 tháng 9, 2014
Cách thêm một bản ghi mới vào trong một bảng dữ liệu có sẵn
Ví dụ: Bảng User( ID,Name,Age)
1. Câu lệnh thực thi thêm dữ liệu
INSERT INTO User VALUES( '1234','tên của bạn',20)
Hoặc
INSERT INTO User( ID,Name,Age) VALUES( '1234','tên của bạn',20)
2. Câu lệnh lấy kết quả vừa thêm mới
SELECT ID,Name,Age FROM User ;
WITH common_table_expression (Transact-SQL)
Specifies a temporary named result set, known as a common table expression (CTE). This is derived from a simple query and defined within the execution scope of a single SELECT, INSERT, UPDATE, or DELETE statement. This clause can also be used in a CREATE VIEW statement as part of its defining SELECT statement. A common table expression can include references to itself. This is referred to as a recursive common table expression.
[ WITH <common_table_expression> [ ,...n ] ] <common_table_expression>::= expression_name [ ( column_name [ ,...n ] ) ] AS ( CTE_query_definition )
-- Define the CTE expression name and column list. WITH Sales_CTE (SalesPersonID, SalesOrderID, SalesYear) AS -- Define the CTE query. ( SELECT SalesPersonID, SalesOrderID, YEAR(OrderDate) AS SalesYear FROM Sales.SalesOrderHeader WHERE SalesPersonID IS NOT NULL ) -- Define the outer query referencing the CTE name. SELECT SalesPersonID, COUNT(SalesOrderID) AS TotalSales, SalesYear FROM Sales_CTE GROUP BY SalesYear, SalesPersonID ORDER BY SalesPersonID, SalesYear; GO
Lấy giá trị của một radio xem đang ở trạng thái check hay chưa check
<input type="radio" id="chktest" name="test"/>
<script>
if ($('[name="test"]').is(':checked'))
</script>
Thứ Tư, 17 tháng 9, 2014
chuyển đổi từ kiểu chuỗi sang kiểu số - và check xem chuỗi truyển vào chỉ là số hay không
int num;
bool isNumeric = int.TryParse(txtNum.text, out num);
if(isNumeric)
{
bool isNumeric = int.TryParse(txtNum.text, out num);
if(isNumeric)
{
// Do your code, the value is number
}
else
{
else
{
// value is not a number
}
Đăng ký:
Bài đăng (Atom)