發表文章

ASP.NET MVC第010天_Model介紹(2)_檢視接收多筆MVC Model資料

圖片
  若要在View上呈現多筆資料 則可以 Step1.預期會有多筆的Model Class先設計好 這裡用的是一個CountryCity的Class 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 using System ; using System.Collections.Generic ; using System.ComponentModel.DataAnnotations ; using System.Linq ; using System.Web ; namespace MVCWebApp1.Models { public class CountryCity { [Required] [Display(Name ="城市")] public string City { get ; set ; } [Required] [Display(Name ="國家")] public string Country { get ; set ; } } } Step2. 在Controller中可以去建立一個ActionResult 函數 返回一個會傳遞某Model陣列的View 1 2 3 4 5 6 7 public ActionResult CountryList () { CountryCity[] cities = new CountryCity[] { new CountryCity() { City = "台北市" , Country = "中華民國台灣" }, new CountryCity () { City = "新北市" , Country = "中華民國台灣" }, ...

T-SQL筆記19_透過指令方式對backup db做匯入_There is insufficient free space on disk volume 'C:\' to create the database.

圖片
  由於近期在還原資料庫過程遇到預設位置在C槽慘狀 There is insufficient free space on disk volume 'C:\' to create the database. The database requires 155512930304 additional free bytes, while only 15410909184 bytes are available. C槽硬碟空間早已用的差不多了 因此勢必要找另一種還原backup方式 SQL語句 1 2 RESTORE DATABASE {DB名稱} FROM DISK = 'D:\TestDB_Full.bak' WITH MOVE '{DB名稱} ' TO 'D:\Data\{DB名稱} .mdf' , MOVE '{DB名稱} _Log' TO 'D:\Data\{DB名稱} _Log.ldf' 當然如果不喜歡下指令然後是圖形化介面派 也可以切至Files去調整預設設在C槽的mdf跟ldf位置 這裡注意要有跳出成功才算完成restore喔!! Ref: Restore SQL Server database from bak file command line https://sqlservergeeks.com/restore-sql-server-database-from-bak-file-command-line/ MS SQL Server - Restoring Databases https://www.tutorialspoint.com/ms_sql_server/ms_sql_server_restoring_databases.htm

T-SQL筆記18_SQL_sqlcmd 指令

圖片
  指令: sqlcmd -? 指令用法 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 sqlcmd - a packet_size - A (dedicated administrator connection ) - b ( terminate batch job if there is an error) - c batch_terminator - C (trust the server certificate) - d db_name - D - e (echo input ) - E (use trusted connection ) - f codepage | i:codepage[,o:codepage] | o:codepage[,i:codepage] - g (enable column encryption) - G (use Azure Active Directory for authentication) - h rows_per_header - H workstation_name - i input_file - I (enable quoted identifiers) - j (Print raw error messages) - k[ 1 | 2 ] (remove or replace control characters) - K application_intent - l login_timeout - L[ c ] (list servers, optional clean output ) - m error_level - M multisubnet_failover - N (encrypt connection ) - o output_file ...

LeetCode第2題_Add Two Numbers(Medium)

圖片
You are given two  non-empty  linked lists representing two non-negative integers. The digits are stored in  reverse order , and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself.   Example 1: Input: l1 = [2,4,3], l2 = [5,6,4] Output: [7,0,8] Explanation: 342 + 465 = 807. Example 2: Input: l1 = [0], l2 = [0] Output: [0] Example 3: Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9] Output: [8,9,9,9,0,0,0,1]   Constraints: The number of nodes in each linked list is in the range  [1, 100] . 0 <= Node.val <= 9 It is guaranteed that the list represents a number that does not have leading zeros. 題目描述:給定兩個非空的連結串列(Linked List),表示兩個非負整數。 這兩個整數以相反的順序存儲,每個節點包含一位數字 。將這 兩個整數相加並以連結串列的形式返回 。 例如,輸入的連結串列為: list1: 2 -> 4 -> 3  代表數字342 list2: 5 -> 6 -> 4  代表數字465 我們知道342+465=807 則返回的連結串列為: 7 -> 0 -...

LeetCode第21題_Merge Two Sorted Lists (Easy)

圖片
https://leetcode.com/problems/merge-two-sorted-lists/ You are given the heads of two sorted linked lists  list1  and  list2 . Merge the two lists in a one  sorted  list. The list should be made by splicing together the nodes of the first two lists. Return  the head of the merged linked list .   Example 1: Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2: Input: list1 = [], list2 = [] Output: [] Example 3: Input: list1 = [], list2 = [0] Output: [0]   Constraints: The number of nodes in both lists is in the range  [0, 50] . -100 <= Node.val <= 100 Both  list1  and  list2  are sorted in  non-decreasing  order. 題目給我們兩個已經排列過的LinkedList 那需要我們把此兩個LinkedList給合在並回傳也排序後的List [1,3,5,7] [2,4,6,8] ->[1,2,3,4,5,6,7,8] 常見錯誤做法: 1.不能單純只透過改pointer來改順序,合併兩個有序列表需要進行元素的比較和選擇,僅僅改變指針的順序無法實現這一目的。 2.直接使用兩個循環進行比較:這種方法通常會忽略兩個列表已經有序的特點,導致不必要的比較操作和額外的時間複雜度。 通常會想成說把node 1指標改從原本指向到3改先安插指到2 node 2的指標再從指向4改接...