DOT NET CORE_API_L1 DB連線?
來源參考:https://www.youtube.com/watch?v=_SprpIlxug8
~appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
//連線字串
"ConnectionStrings":{
"DefaultConnection":"Data Source=127.0.0.1;Initial Catalog=DBJosh;User ID=Josh;Password=123456"
},
"AllowedHosts": "*"
}
-----------------------------------------
~Startup.cs
using *;
//**************手動補上 命名空間
using Microsoft.Extensions.Configuration; //ConfigurationBuilder 會用到
using System.IO; //Directory 會用到
using System.Data.SqlClient; //SQL
using System.Text.Encodings.Web; //HtmlEcoder會用到(處理中文編碼)
//**************************END
namespace webapi
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.Run(async (context) =>
{
// await context.Response.WriteAsync("Hello World!");
//連線字串在appsetting.json 裡
var configurationBuilder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
IConfiguration config = configurationBuilder.Build();
string connectionString = config["ConnectionStrings:DefaultConnection"];
var Conn = new SqlConnection(connectionString);
Conn.Open();
var Com = new SqlCommand("SELECT u_area FROM tb_User WHERE u_no = @u_no", Conn);
Com.Parameters.AddWithValue("u_no", 1);
using (SqlDataReader dr = Com.ExecuteReader()) {
while (dr.Read()) {
//1.中文亂解決--瀏覽器改UTF8
var title = dr["u_area"];
await context.Response.WriteAsync("<br />"+ title +"<hr />");
//2.中文亂碼解決 -- 不用修改瀏覽器--請加入 using System.Text.Encodings.Web;
var title2 = HtmlEncoder.Default.Encode(dr["u_area"].ToString());
await context.Response.WriteAsync("<br />" + title2+ "<hr />");
}
}
Conn.Close();
});
}
}
}
SHOWcode
2020年2月23日 星期日
2020年2月11日 星期二
Trigger UPDATE,INSERT,DELETE
資料更改時同時寫入另一個表
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TRIGGER [ TRIGGER名稱 ] ON [ 主TABLE] AFTER UPDATE,INSERT,DELETE
AS
BEGIN
IF EXISTS (SELECT 1 FROM inserted) AND EXISTS (SELECT 1 FROM deleted)
BEGIN
INSERT INTO [ 寫入的TABLE] SELECT 'UPDATE',* FROM inserted
END
ELSE IF EXISTS (SELECT 1 FROM inserted) AND NOT EXISTS (SELECT 1 FROM deleted)
INSERT INTO [ 寫入的TABLE] SELECT 'INSERT',* FROM inserted
ELSE IF NOT EXISTS (SELECT 1 FROM inserted) AND EXISTS (SELECT 1 FROM deleted)
INSERT INTO [ 寫入的TABLE] SELECT 'DELETE',* FROM deleted
END
USE [dbMES] GO /****** Object: Trigger [dbo].[tb_recordslog_Modify] Script Date: 2020/4/30 上午 09:00:44 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <KIRA> -- Create date: <20160727> -- Description: <Device setting> -- ============================================= ALTER TRIGGER [dbo].[tb_recordslog_Modify] on [dbo].[tb_recordslog] AFTER INSERT AS BEGIN --表格異動資料時會產生暫存的inserted和deleted兩個表格 --兩個表格格式資訊皆與原表格相同 --inserted紀錄insert資料、update後資料 --deleted紀錄delete資料、update前資料 --依據異動方式將異動資料新增到記錄檔 --inserted和deleted皆有資料表示為-UPDATE --inserted有資料deleted無資料表示為-INSERT IF EXISTS (select 1 from inserted) and Not EXISTS (select 1 from deleted) insert into tb_recordslog_1 select DID,DIP,SID,DVALUE,SYSTIME from inserted END
USE [dbMES] GO /****** Object: Trigger [dbo].[tb_recordslog_Modify] Script Date: 2020/4/30 上午 09:00:44 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <KIRA> -- Create date: <20160727> -- Description: <Device setting> -- ============================================= ALTER TRIGGER [dbo].[tb_recordslog_Modify] on [dbo].[tb_recordslog] AFTER INSERT AS BEGIN --表格異動資料時會產生暫存的inserted和deleted兩個表格 --兩個表格格式資訊皆與原表格相同 --inserted紀錄insert資料、update後資料 --deleted紀錄delete資料、update前資料 --依據異動方式將異動資料新增到記錄檔 --inserted和deleted皆有資料表示為-UPDATE --inserted有資料deleted無資料表示為-INSERT IF EXISTS (select 1 from inserted) and Not EXISTS (select 1 from deleted) insert into tb_recordslog_1 select DID,DIP,SID,DVALUE,SYSTIME from inserted END
2020年2月3日 星期一
json 多table 分類 抓法
json 多table 分類 抓法
---Json--
{
"first":[
{"name":"張三","sex":"男"},
{"name":"李四","sex":"男"},
{"name":"王武","sex":"男"},
{"name":"李梅","sex":"女"}
],
"first01":[
{"name":"張3","sex":"男"},
{"name":"李4","sex":"男"},
{"name":"王5","sex":"男"},
{"name":"李6","sex":"女"}
]
}
----Jscript ----
<script src="js/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var jqxhr = $.getJSON("./data_json/data/data.json", function () {
console.log("success");
})
//如果有這檔案會印出success
//$.getJSON("./data_json/Resonator_json/tl8oh-63gm2.json", function (json) {
// alert("JSON Data: " + json.name);
//});
//讀出json屬性的值,name是KEY,根據自己KEY定義改
//debugger;
var info = document.querySelector('.info');
var str = "";
$.getJSON("./data_json/data/data.json", function (json_data) {
//var len = json_data.first.length; //first表資料比數
var len = json_data.first01.length; //first01表資料比數
if (len != 0) {
for (var i = 0; i < len; i++) {
//var content = '<tr>' + '<td>' + json_data.first[i].name + ' </td>' + '<td>' + json_data.first[i].sex + '</tr>';
var content = '<tr>' + '<td>' + json_data.first01[i].name + ' </td>' + '<td>' + json_data.first01[i].sex + '</tr>';
//console.log(content);
str += content;
};
} else {
var content = '<tr>' + '<td>Null</td>' + '<td>Null</td>' + '</tr>';
//console.log(content);
str += content;
}
info.innerHTML += str;
});
//將JSON印成字串
});
</script>
----------------Html-------
<table class="table">
<thead>
<tr>
<th scope="col">Classification</th>
<th scope="col"> Part No.</th>
</tr>
</thead>
<tbody class="info">
</tbody>
</table>
Jquery 抓Json 資料
<script src="js/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var jqxhr = $.getJSON("./data_json/Filter_json/j97hq-92dsm_n.json", function () {
console.log("success");
})
//如果有這檔案會印出success
//$.getJSON("./data_json/Resonator_json/tl8oh-63gm2.json", function (json) {
// alert("JSON Data: " + json.name);
//});
//讀出json屬性的值,name是KEY,根據自己KEY定義改
//debugger;
var info = document.querySelector('.info');
var str = "";
$.getJSON("./data_json/Filter_json/j97hq-92dsm_n.json", function (json_data) {
// console.log(JSON.stringify(json));
// debugger;
var len = json_data.length; //資料比數
if (len != 0) {
for (var i = 0; i < len; i++) {
// var content = '<tr>' + '<td>名稱:' + datastr[i].name + ' </td>' + '<td>value_a:' + datastr[i].value_a + ' </td>' + '<td>value_b:' + datastr[i].value_b + ' </td>' + '<td>value_c:' + datastr[i].value_c + ' </td>' + '<td>value_d:' + datastr[i].value_d + ' </td>' + '<td>value_e:' + datastr[i].value_e + ' </td>' + '</tr>';
var content = "";
if (json_data[i].value_url != 'Null') {
content = '<tr>' + '<td> <a href="./pdf/Datasheet/' + json_data[i].value_url + '" target="_blank"> ' + json_data[i].name + '<img src="./img/pdf-download.png" width="51px" height="35px"></a></td>' + '<td>' + json_data[i].value_a + ' </td>' + '<td>' + json_data[i].value_b + ' </td>' + '<td>' + json_data[i].value_c + ' </td>' + '<td>' + json_data[i].value_d + ' </td>' + '<td> </td>' + '</tr>';
} else {
content = '<tr>' + '<td>' + json_data[i].name + ' </td>' + '<td>' + json_data[i].value_a + ' </td>' + '<td>' + json_data[i].value_b + ' </td>' + '<td>' + json_data[i].value_c + ' </td>' + '<td>' + json_data[i].value_d + ' </td>' + '<td> </td>' + '</tr>';
}
//console.log(content);
str += content;
};
} else {
var content = '<tr>' + '<td>Null</td>' + '<td>Null</td>' + '<td>Null</td>' + '<td>Null</td>' + '<td>Null</td>' + '<td>Null</td>' + '</tr>';
//console.log(content);
str += content;
}
info.innerHTML += str;
});
//將JSON印成字串
});
</script>
----Html-----
<div class="table-responsive">
<nobr>
<table class="table">
<thead>
<tr>
<th scope="col">Part</th>
<th scope="col">Frequency</th>
<th scope="col">Bandwidth</th>
<th scope="col">Lid Symbol</th>
<th scope="col">Dimension</th>
<th scope="col">Automotive</th>
</tr>
</thead>
<tbody class="info">
</tbody>
</table>
</nobr>
</div>
nginx服务无法停止(Windows)
nginx服务无法停止(Windows)
本文链接:https://blog.csdn.net/qq_36133698/article/details/88582539
本人一般停止nginx服务都是通过Windows自带的任务管理器来强制结束nginx进程实现的,如图
但是 这次我通过同样的方法来结束nginx服务,发现nginx的进程无法结束
首先我要确认了nginx服务还在运行,因为nginx是web服务器,正常启动的话,是可以访问它的网页的。例如:我们在浏览器中输入:127.0.0.1:8888(默认监听80端口,我这里修改了nginx.conf监听8888端口) 回车后,应该能看到一个欢迎页面(没有改默认网页的情况)。如果能够看到, 说明nginx启动正常。
然后我进入nginx根目录通过命令停止nginx服务,结果报错 如图
意思是nginx服务没有启动 所以nginx服务停止报错 这就很诡异啦 ngnix明明在偷偷运行 这里为啥会提示nginx没有运行呢。因为我的nginx监听的是8888端口 所以我就想 既然终端提示nginx服务停止了那8888端口就不会被监听,但是nginx的web页面可以访问 说明8888端口还在被监听 我只需要把监听8888端口的进程全部kill就可以停止nginx服务啦
cmd 输入命令 netstat -ano 如图 找到nginx监听端口的pid
通过cmd 命令tasklist|findstr "PID" 如图 找到监听8888端口的进程
确实发现有nginx服务在运行 通过cmd命令 taskkill /f /t /im nginx.exe 结束进程 结果如图
最后访问127.0.0.1:8888 失败 说明nginx服务被成功停止
訂閱:
文章 (Atom)
Jenkins-mail
參考:http://www.linuxea.com/1767.html 前置作業略過~有空再補 Mailer Plugin post { success { emailext ( subject: &...
-
ASP.NET刷新頁面的六種方法 第一: private void Button1_Click( object sender, System.EventArgs e ) { Response.Redirect( Request.Url.ToSt...
-
foreach (string fname in System.IO.Directory.GetFileSystemEntries(@"C:\Users\joshs")) { //if (fn...