2014年11月11日 星期二

VB SQL 資料庫讀取資料

一、抓到 datagridview
Dim sqlstr As New String("SELECT   年度薪資.姓名, 年度薪資.員工編號" & _
        " FROM    where year(年度薪資.發薪日期)=" & TextBox1.Text & " group by 年度薪資.姓名, 年度薪資.員工編號 ;")

        Dim da As New SqlDataAdapter(sqlstr, MDIParent1.conn)
        Dim cb As New SqlCommandBuilder(da)

        da.Fill(Data)
        DataGridView1.DataSource = Data

二、reader 一筆一筆讀取
Dim sqlquery As String
      sqlquery = "select count(姓名) from 考核獎金 where 年度='" & TextBox1.Text & "' and 次數='" & TextBox2.Text & "';"
        Dim cmnd As SqlCommand = New SqlCommand(sqlquery, MDIParent1.conn)  
        Dim reader As SqlDataReader
        reader = cmnd.ExecuteReader()
        While (reader.Read())
            If reader.IsDBNull(0) = False Then
                havedata = reader.GetValue(0)
            End If
        End While
        reader.Close()

2014年5月15日 星期四

VB 計算每月的例假日天數

 Public Function GetholiDays(ByVal theYear As Integer, ByVal theMonth As Integer) As Integer
        Dim theDays As Integer = 8
        Dim x, y As Integer
        Dim dt As New DateTime(theYear, theMonth, 1)
        x = DateTime.DaysInMonth(theYear, theMonth) - 28

        If dt.DayOfWeek.ToString() = "Monday" Then y = 1
        If dt.DayOfWeek.ToString() = "Tuesday" Then y = 2
        If dt.DayOfWeek.ToString() = "Wendnesday" Then y = 3
        If dt.DayOfWeek.ToString() = "Thursday" Then y = 4
        If dt.DayOfWeek.ToString() = "Friday" Then y = 5
        If dt.DayOfWeek.ToString() = "Saturday" Then y = 6
        If dt.DayOfWeek.ToString() = "Sunday" Then y = 7
     
        If x + y = 7 Then
            theDays = 9
        ElseIf x + y >= 8 Then
            theDays = 10
        End If
        If y = 7 Then theDays = theDays - 1

        Return theDays
    End Function

2013年9月1日 星期日

封鎖臉書應用程式(遊戲)的廣告訊息

      臉書上經常會接到一些好友邀請遊戲的廣告訊息,若很煩可以針對此遊戲(應用程式)將其關閉封鎖,如此以後就算好友邀請也不會出現在通知訊息上了。
       作法很簡單,只要在訊息上右邊 上按下去即可,然後再按一次關閉就完成了。若要檢舉他就點檢舉垃圾訊息應用程式。
     

如果相同的人經常發這總訊息給你,就可以針對此人所發送的應用程式(遊戲)邀請作封鎖。在設定中點選封鎖/封鎖應用程式邀請/輸入好友名稱/點選進入即可






2013年6月9日 星期日

WORD錯誤訊息:文件已儲存,但因儲存空間不足,導致語音辨識資料遺失

使用者嘗試開啟或儲存含有先前舊版 Microsoft Office 中修改或儲存 OfficeArt 圖形的 Microsoft Office PowerPoint 2003、Word 2003、Excel 2003 的檔案時可能發生的問題。
解決方法:在WORD工具/選項/儲存/內嵌語言資料取消不選!

2013年4月6日 星期六

google 地圖製作


在地圖頁中輸入地址,標示正確位置,若已建立商家資訊則可顯示出來商家位置
點選連結標籤,複製HTML 語法到網站或部落格,在HTML編輯模式中貼上,即可在您的網站或部落格顯示商家位置











顯示結果
檢視較大的地圖

2013年4月3日 星期三

word無法直接開啟檔案,只會開啟程式

在word/說明,選擇偵測與修復功能,然後選擇還原成預設值,按開始即可解決問題

2013年3月6日 星期三

網頁、php、Mysql 中文問題

1.欄位用中文,加上 mysql_query("SET NAMES ‘UTF8′");網頁編碼為big5
取出的欄位名稱會是亂碼;
栽 種 品 :
產 品 品 質 :
備 註:

�W�摨�w_sngdateproductqulmess
1234524212410000-00-00qwdqweqwefgrggh
1243342532352013-01-23
1223312311111110000-00-00
121432132350000-00-00
同樣程式碼,網頁編碼為UTF8




2.欄位名稱用英文,select 使用中文別名,則出現錯誤訊息

mysql_query("SET NAMES ‘UTF8′");
$result=mysql_query("Select p_sn 產品序號 from cut  ");


Warning: mysql_fetch_field(): supplied argument is not a valid MySQL result resource inC:\AppServ\www\manage\factor\cut.php on line 92


require("../factor/db.php");                     //匯入資料庫設定檔
//require("../彥廷農場/checkform.php");             //匯入欄位檢查檔
//require("../彥廷農場/double.php"); //檢查帳號是否重覆
echo "";



/* 顯示會員資料 */
//mysql_query("SET NAMES ‘UTF8′");
$result=mysql_query("Select * from cut where 產品序號='12345' ");//,order by p_sn desc w_sn B, gdate 日期, product 收穫品, qul 品質, mess 備註

echo "<table border=1>\n"; 
echo "<tr>\n";
/*印出表頭*/
while ($field=mysql_fetch_field($result)) {
echo "<td>".$field->name."</td>\n"; 
}
echo "</tr>\n";
/*印出表身*/
while ($row=mysql_fetch_row($result)) {
echo "<tr>\n";
for ($i=0;$i<count($row);$i++ ){
echo "<td>".$row[$i]."</td>";
}
echo "<tr>\n";
}
?>
<form method="post" action="" accept-charset="big5">
*產 品 序 號 :<input type="text" name="p_sn"><br/> 
*剪蒂人員編號:<input type="text" name="w_sn"><br/>
*日       期:<input type="date" name="gdate" ><br/> 
栽  種  品  :<input type="text" name="product"><br/>
產 品 品 質 :<input type="text" name="qul"><br/> 
備        註:<input type="text" name="mess"><br/> 
<input type="submit" value="新增">
</form>
<?php
require("../factor/db.php");
$p_sn=$_POST['p_sn'];
$w_sn=$_POST["w_sn"];
$gdate=$_POST["gdate"];
$product=$_POST["product"];
$qul=$_POST["qul"];
$mess=$_POST["mess"];

/* 檢查帳號與密碼欄位是否為空白 */
if (empty($p_sn) || empty($w_sn) || empty($gdate))
{
  echo "*號欄位一定要填喔!";
  exit;
}
/* 將欄位資料插入資料庫 */
$sql="INSERT cut (p_sn,w_sn,gdate,product,qul,mess)
VALUES ('$p_sn','$w_sn','$gdate','$product','$qul','$mess')";
mysql_query($sql);
?>