วันพุธที่ 14 มีนาคม พ.ศ. 2561

SQL Server : Delete multiple Stored Procedures in One Database

SELECT 'DROP PROCEDURE [' + SCHEMA_NAME(p.schema_id) + '].[' + p.NAME + ']'
FROM sys.procedures p  WHERE p.name like 'SSIS%'
ORDER BY p.name

SQL Server : Delete all tables in a SQL Server database

DECLARE @Sql NVARCHAR(500) DECLARE @Cursor CURSOR

SET @Cursor = CURSOR FAST_FORWARD FOR
SELECT DISTINCT sql = 'ALTER TABLE [' + tc2.TABLE_NAME + '] DROP [' + rc1.CONSTRAINT_NAME + ']'
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc1
LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc2 ON tc2.CONSTRAINT_NAME =rc1.CONSTRAINT_NAME

OPEN @Cursor FETCH NEXT FROM @Cursor INTO @Sql

WHILE (@@FETCH_STATUS = 0)
BEGIN
Exec sp_executesql @Sql
FETCH NEXT FROM @Cursor INTO @Sql
END

CLOSE @Cursor DEALLOCATE @Cursor
GO

EXEC sp_MSforeachtable 'DROP TABLE ?'
GO

Windows 10: Windows Update error 0x8024401c

Windows Update Error Message : There were some problems installing updates, but we'll try again later. If you keep seeing this and want to search the web or contact support for information, this may help: (0x8024401c)

2. Download Fix Windows Update program.



 3. Save.


4. When you success download Click run program.
5. Select Next and follow the steps.


วันจันทร์ที่ 26 กุมภาพันธ์ พ.ศ. 2561

Forget user & password Apache Tomcat


   
 1. Go to folder apache tomcat  for example : C:\apache-tomcat-7.0.84\conf 

  
 2. Open file tomcat-users.xml by Notepad


3. Focus tag
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="both" roles="tomcat,role1"/>
<user username="role1" password="role1" roles="role1"/>
Uncomment all tag or add another user and user role 


4. Open command 
go to apache-tomcat-7.0.84\bin 
> shutdown 
 > Enter

5. Open command 
go to apache-tomcat-7.0.84\bin 
 > startup
 > Enter

6. Success.





วันพฤหัสบดีที่ 8 กุมภาพันธ์ พ.ศ. 2561

แก้ Error 500.19 บน IIS


วิธีแก้
1. ไปที่ Control Panel
2. ที่มุมขวาบน เลือก View  by : category
3. ที่หัวข้อ Programs เลือก Uninstall a program
4. ที่แถบซ้ายมือเลือก Turn windows feature on or off
5. ในลิสต์ของ Internet Information Services
     > World Wide Web Services
     > Application Deployment Features
     > เลือก .Net ที่เป็น version ล่าสุด ตามภาพด่านล้าง
     > OK
จากนั้นรอซักครู่ให้ feature โหลดเรียบร้อยแล้วรีเฟรสหน้าเว็บ



วันพุธที่ 8 มีนาคม พ.ศ. 2560

CSS [ Transparent Drop Down Navigation Menu with CSS and HTML ]


Credit: clevertechie
ประกอบไปด้วย 2 ส่วนคือ HTML และ CSS
รูปภาพจาก https://clevertechie.com/files/nature.jpg

1. HTML Source code

<html>
<link href="style.css" rel="stylesheet">
<ul>
<li><a>Home</a></li>
<li><a>About</a>
<ul>
<li><a>Our Team</a></li>
<li><a>Campian Sites</a></li>
<li><a>Mission &amp; Vision</a></li>
<li><a>Resource</a></li>
</ul>
</li>
<li><a>Think to do</a>
<ul>
<li><a>Activities</a></li>
<li><a>Parks</a></li>
<li><a>Shops</a></li>
<li><a>Events</a></li>
</ul>
</li>
<li><a>Contract</a>
<ul>
<li><a>Map</a></li>
<li><a>Directions</a></li>
</ul>
</li>
<li><a>News</a></li>
</ul>
</html>

2 . CSS Source code

body{
background:url('nature.jpg') no-repeat;
background-size:cover;
font-family:Arial;
color:white;
}
ul{
margin:0px;
padding:0px;
list-style:none;
}
ul li{
float:left;
width:250px;
height:40px;
background-color:black;
opacity:.8;
line-height:40px;
text-align:center;
font-size:20px;
margin-right:2px;
}
ul li a{
text-decoration:none;
color:white;
display:block;
}
ul li a:hover{
background-color:green;
}
ul li ul li{
display:none;
}
ul li:hover ul li{
display:block;
}

C# Language [ ตัวอย่างระบบโอนเงิน (จากต้นทางไปปลายทาง) ]

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace BankAccount
{
{
{
InitializeComponent();
}
{
{
cmd.Connection = c;
cmd.CommandText = "select top 1 balance from userAccount where accountName = @userAccountId";
cmd.Parameters.AddWithValue(

cmd.Parameters.AddWithValue("userAccountId","admin");
cmd.Connection.Open();

cmd.Connection.Open();


double balance = Convert.ToDouble(cmd.ExecuteScalar());

if (balance < Convert.ToDouble(txtm.Text.Trim()))
{

{
MessageBox.Show("เงินของท่านไม่เพียงพอในการโอน");
cmd.Connection.Close();

cmd.Connection.Close();return;
}

}
cmd.CommandText =@"
update userAccount set balance = @balanceDestination where accountName = @userAccountId_Destination;
update userAccount set balance = @balanceTarget where accountName = @userAccountId_Target
"

update userAccount set balance = @balanceDestination where accountName = @userAccountId_Destination;
update userAccount set balance = @balanceTarget where accountName = @userAccountId_Target
";//เป็นการแอดชื่อ พรามิเตอร์ที่เราใช้มา(ตัวที่เราใช้,ค่าที่เราเอา มาจากไหน)cmd.Parameters.AddWithValue("userAccountId_Destination", "admin");
cmd.Parameters.AddWithValue(

cmd.Parameters.AddWithValue("balanceDestination", balance - Convert.ToDouble(txtm.Text.Trim()));
cmd.Parameters.AddWithValue(

cmd.Parameters.AddWithValue("balanceTarget", balance + Convert.ToDouble(txtm.Text.Trim()));
cmd.Parameters.AddWithValue(

cmd.Parameters.AddWithValue("userAccountId_Target",txtget.Text.Trim());
{
}
}
}
}
}
}
}


public partial class FormTransfer : Form{public FormTransfer()

private void btnOK_Click(object sender, EventArgs e)
using (SqlConnection c = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=""C:\Documents and Settings\students\My Documents\Visual Studio 2005\Projects\BankAccountSS\BankAccountSS\BankDB.mdf"";Integrated Security=True;User Instance=True"))
SqlCommand cmd = new SqlCommand();

else

{
if (cmd.ExecuteNonQuery() > 0)
MessageBox.Show("เงินได้ถูกโอนไปยังบัญชีปลายทางเรียบร้อยแล้ว");
else{
MessageBox.Show("ระบบขัดข้อง");
}
}

Search Table Name of all database [ ค้นหาชือ Table ใน Database server ทั้งหมด ]

  -------------- -- Search Table Name inside database server -- 1. -------------- DECLARE @SearchTerm NVARCHAR ( 100 ) = '% TableN...