2023年12月27日 星期三

DataTables Editor examples index

Editor examples index 



DataTable Simple inline editing

 Datatables Simple inline editing


DataTable Multi-row editing

 datatables Multi-row editing



The Ultimate Facebook SDK for .NET

 The Ultimate Facebook SDK for .NET

Facebook C# SDK v5 Beta Internals

還很多,請查看原址   prabir's


Consuming ASP.NET Web Services using JQuery

 Consuming ASP.NET Web Services using JQuery


Using jqGrid with ASP.NET Web Forms

Using jqGrid with ASP.NET Web Forms - Part I

 Using jqGrid with ASP.NET Web Forms - Part II


2023年12月23日 星期六

gridview固定列的寬度並且能換行

 在RowCreated事件中添加

e.Row.Cells[6].Attributes.Add("style", "word-break :break-all ; word-wrap:break-word");


這樣則會讓你選定的列自動換行了 不過前提是要給列設定寬度

<asp:BoundField DataField="Memo" HeaderText="備忘" >

<ItemStyle Width="20%" Wrap="True" />

</asp:BoundField>

前台這樣寫。 注意: Wrap="True" 啊!


上面只能對單一的列其作用。


下面是全域的,寫到CSS裡最好不過了。

GridView.Attributes.Add( "style ", "table-layout:fixed ")

2023年12月5日 星期二

具有潛在危險 request.form 的值已從用戶端

 參考引用:Net的網站操作中,有時會出現『具有潛在危險 Request.Form 的值已從用戶端偵測


可以透過在頁面的Page指示詞中加入 validateRequest="False" 來關閉這個功能:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test123.aspx.vb" Inherits="Test" validateRequest="False" %>


或是在 web.config 設定檔關閉:

<system.web>

    <pages validateRequest="False" />

</system.web>


 


不過,如此一來網頁程式中就該在輸入欄位加上HttpUtility.HtmlEncode方法,將字串轉換為 HTML 編碼的字串,再用HttpUtility.HtmlDecode將已經為 HTTP 傳輸而進行 HTML 編碼的字串轉換為解碼的字串,以避免駭客的惡意攻擊。

加密:

URL="Test123.aspx?id=" & HttpUtility.HtmlEncode(id.text)

Server.Transfer(URL)

解密:

ID=HttpUtility.HtmlDecode(Request("id"))


2023年11月20日 星期一

VB.NET Multithreading

 參考來源:VB.NET Multithreading

*** Create a new Thread ***


Imports System.Threading 'Imports the System.Threading namespace.   

Module create_Thread  

    Sub Main(ByVal args As String())  

        ' create a new thread   

        Dim th As Thread = New Thread(New ThreadStart(AddressOf PrintInfo))  

        ' start the newly created thread  

        th.Start()  

        Console.WriteLine(" It is a Main Thread")  

    End Sub  

    Private Sub PrintInfo()  

        For j As Integer = 1 To 5  

            Console.WriteLine(" value of j is {0}", j)  

        Next j  

        Console.WriteLine(" It is a child thread")  

        Console.WriteLine(" Press any key to exit...")  

        Console.ReadKey()  

    End Sub  

End Module  



*** VB.NET Thread Life Cycle ***

Imports System.Threading  

Module Thread_cycle  

    Sub Main(ByVal args As String())  

        Dim s As Stopwatch = New Stopwatch()  

        s.Start()  

        Dim t As Thread = New Thread(New ThreadStart(AddressOf PrintInfo))  

        t.Start()  

        ' Halt another thread execution until the thread execution completed  

        t.Join()  

        s.[Stop]()  

        Dim t1 As TimeSpan = s.Elapsed  

        Dim ft As String = String.Format("{0}: {1} : {2}", t1.Hours, t1.Minutes, t1.Seconds)  

        Console.WriteLine(" Total Elapsed Time : {0}", ft)  

        Console.WriteLine("Completion of Thread Execution ")  

        Console.WriteLine("Press any key to exit...")  

        Console.ReadKey()  

    End Sub  

    Private Sub PrintInfo()  

        For j As Integer = 1 To 6  

            Console.WriteLine(" Halt Thread for {0} Second", 5)  

            ' It pause thread for 5 Seconds  

            Thread.Sleep(5000)  

            Console.WriteLine(" Value of i {0}", j)  

        Next  

    End Sub  

End Module  




*** Multithreading ***

 Imports System.Threading  

Module Multi_thread  

    Sub Main(ByVal arg As String())  

        Dim th As Thread = New Thread(New ThreadStart(AddressOf PrintInfo))  

        Dim th2 As Thread = New Thread(New ThreadStart(AddressOf PrintInfo2))  

        th.Start()  

        th2.Start()  

        Console.ReadKey()  

    End Sub  

    Private Sub PrintInfo()  

        For j As Integer = 1 To 5  

            Console.WriteLine(" value of j is {0}", j)  

            Thread.Sleep(1000)  

        Next  

        Console.WriteLine(" Completion of First Thread")  

    End Sub  

    Private Sub PrintInfo2()  

        For k As Integer = 1 To 5  

            Console.WriteLine(" value of k is {0}", k)  

        Next  

        Console.WriteLine(" Completion of First Thread")  

    End Sub  

End Module  


VB.NET Thread 多緒回傳

 ************Thread沒參數************


Public Class Class1

    Event EvnetRecall As EventHandler '用事件回傳結果

    Sub Add()

        Dim Show As Integer = 0

        Dim Add As Integer = 1

        For i = 0 To 10000 Step Add

            Show += i

        Next i

        Debug.WriteLine("Add執行緒:" & System.Threading.Thread.CurrentThread.ManagedThreadId)

        RaiseEvent EvnetRecall(Show, EventArgs.Empty)

    End Sub

End Class



Public Class Form1

    Dim A As New Class1


#Region "多緒"

    Public Sub TH_Add()

        Dim Thread1 As New System.Threading.Thread(New System.Threading.ParameterizedThreadStart(AddressOf A.Add)) '設定Class為多緒

        Thread1.Name = "TH_Add"

        Thread1.Start()

    End Sub


    Public Delegate Sub TH_Add_Show(ByVal sander As Integer) '宣告委派TH_Add_Show


    Sub TH_AIGroupData_EventHandler(ByVal sender As Integer, ByVal e As System.EventArgs) '委派事件接收

        Me.BeginInvoke(New TH_Add_Show(AddressOf TH_Add_Show_Do), sender)

    End Sub

    Public Sub TH_Add_Show_Do(ByVal sender As Integer) '接收到事件後要執行的動作

        TextBox1.Text = sender

    End Sub

#End Region


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        AddHandler A.EvnetRecall, AddressOf TH_AIGroupData_EventHandler '共用事件

        TH_Add()

    End Sub

End Class









************Thread有參數************



Public Class Class1

    Event EvnetRecall As EventHandler '用事件回傳結果


    Public Structure StarAndStep

        Public Start As Integer

        Public StepInt As Integer

    End Structure


    Sub Add(ByVal Obj As StarAndStep)

        Dim Show As Integer = 0

        Dim Add As Integer = 1

        For i = 0 To 10000 Step Obj.StepInt

            Obj.Start += i

        Next i

        Debug.WriteLine("Add執行緒:" & System.Threading.Thread.CurrentThread.ManagedThreadId)

        RaiseEvent EvnetRecall(Obj.Start, EventArgs.Empty)

    End Sub

End Class



Public Class Form1


    Dim A As New Class1

#Region "多緒"

    Public Sub TH_Add(ByVal Obj As Object)

        Dim Thread1 As New System.Threading.Thread(New System.Threading.ParameterizedThreadStart(AddressOf A.Add)) '設定副程式為多緒

        Thread1.Name = "TH_Add"

        Thread1.Start(Obj)

    End Sub


    Public Delegate Sub TH_Add_Show(ByVal sander As Object) '宣告委派TH_Add_Show


    Sub TH_AIGroupData_EventHandler(ByVal sender As Object, ByVal e As System.EventArgs) '委派事件接收

        Me.BeginInvoke(New TH_Add_Show(AddressOf TH_Add_Show_Do), sender)

    End Sub

    Public Sub TH_Add_Show_Do(ByVal sender As Object) '接收到事件後要執行的動作

        TextBox1.Text = sender

    End Sub

#End Region


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        AddHandler A.EvnetRecall, AddressOf TH_AIGroupData_EventHandler '共用事件

        Dim StarStep As New Class1.StarAndStep

        StarStep.Start = 0

        StarStep.StepInt = 2

        TH_Add(StarStep)

    End Sub

End Class


2023年11月9日 星期四

2023年11月6日 星期一

資源集區'internal' 中的系統記憶體不足,無法執行此查詢

 sp_configure 'show advanced options', 1;

GO

RECONFIGURE;

GO

sp_configure 'max server memory', 2147483647;

GO

RECONFIGURE;

GO

---------------------


EXEC sp_configure 'show advanced options', '1' RECONFIGURE WITH OVERRIDE;

EXEC sp_configure 'max server memory', 2147483647 RECONFIGURE WITH OVERRIDE;

EXEC sp_configure 'show advanced options', '0' RECONFIGURE WITH OVERRIDE;


---------------------


 DBCC FREESYSTEMCACHE ('ALL'); --釋放所以在快取內,未被使用的項目

 DBCC FREEPROCCACHE; --從計畫快取移除所有元素

 DBCC DROPCLEANBUFFERS; --清除緩衝區裡面的所有暫存項目

 DBCC FREESESSIONCACHE; --清除所有查詢所使用的分散式連線快取

2023年10月12日 星期四

模擬器效能的硬體加速 (Hyper-V & HAXM)

 模擬器效能的硬體加速 (Hyper-V & HAXM)

---

啟用 Hyper-V 加速

如果您的電腦符合上述準則,請使用下列步驟,使用 Hyper-V 來加速 Android Emulator:

在 Windows 搜尋方塊中輸入 Windows 功能,然後在搜尋結果中選取 [開啟或關閉 Windows 功能]。 

在 [Windows 功能] 對話方塊中,同時啟用 Hyper-V 與 Windows Hypervisor 平台:

啟用 Hyper-V 和 Windows Hypervisor 平臺




進行這些變更之後,請重新啟動電腦。


.NET 多平臺應用程式 UI (.NET MAUI)

.NET 多平臺應用程式 UI 檔

 


Xamarin 文件

 Xamarin 文件

由於使用 Xamarin 建置的應用程式為原生應用程式,因此有固有的外觀及操作。


開放原始碼

根據 MIT 授權提供

Xamarin SDK、Xamarin.Forms 和 Mono 執行階段為 GitHub 上的開放原始碼。 歡迎您投稿!

Repos:
文件:
聊天:

Android Studio 在開發時使用 Google Play 遊戲電腦版開發人員模擬器

 在開發時使用 Google Play 遊戲電腦版開發人員模擬器

---


developer android 官網


2023年9月24日 星期日

WAITFOR (Transact-SQL)

 引用來源:WAITFOR (Transact-SQL)

----

範例

A. 使用 WAITFOR TIME

下列範例會在下午 10:20 (22:20) 執行 msdb 資料庫中的預存程序 sp_update_job。


SQL


複製

EXECUTE sp_add_job @job_name = 'TestJob';  

BEGIN  

    WAITFOR TIME '22:20';  

    EXECUTE sp_update_job @job_name = 'TestJob',  

        @new_name = 'UpdatedJob';  

END;  

GO  

B. 使用 WAITFOR DELAY

下列範例會在延遲兩小時之後執行預存程序。


SQL


複製

BEGIN  

    WAITFOR DELAY '02:00';  

    EXECUTE sp_helpdb;  

END;  

GO  

C. 搭配本機變數來使用 WAITFOR DELAY

下列範例顯示如何搭配 WAITFOR DELAY 選項來使用本機變數。 這預存程序會等待一陣可變的時段,再將經歷的時、分、秒數資訊傳回給使用者。


SQL


複製

IF OBJECT_ID('dbo.TimeDelay_hh_mm_ss','P') IS NOT NULL  

    DROP PROCEDURE dbo.TimeDelay_hh_mm_ss;  

GO  

CREATE PROCEDURE dbo.TimeDelay_hh_mm_ss   

    (  

    @DelayLength char(8)= '00:00:00'  

    )  

AS  

DECLARE @ReturnInfo VARCHAR(255)  

IF ISDATE('2000-01-01 ' + @DelayLength + '.000') = 0  

    BEGIN  

        SELECT @ReturnInfo = 'Invalid time ' + @DelayLength   

        + ',hh:mm:ss, submitted.';  

        -- This PRINT statement is for testing, not use in production.  

        PRINT @ReturnInfo   

        RETURN(1)  

    END  

BEGIN  

    WAITFOR DELAY @DelayLength  

    SELECT @ReturnInfo = 'A total time of ' + @DelayLength + ',   

        hh:mm:ss, has elapsed! Your time is up.'  

    -- This PRINT statement is for testing, not use in production.  

    PRINT @ReturnInfo;  

END;  

GO  

/* This statement executes the dbo.TimeDelay_hh_mm_ss procedure. */  

EXEC TimeDelay_hh_mm_ss '00:00:10';  

GO  

以下為結果集。


A total time of 00:00:10, in hh:mm:ss, has elapsed. Your time is up.

2023年9月20日 星期三

c# Google Protocol Buffer

 C#教程之《Dotnet9》系列-Google ProtoBuf在C#中的简单应用

--

github protocolbuffers protobuf


grpc 官網

 github grpc


C# 搭配 gRPC 中使用 stream RPC

 C# 搭配 gRPC 中使用 stream RPC

---


完整程式碼請參考  dotnetgrpcstream

--


gRPC 相關

 什麼是 gRPC

什麼是 gRPC(二)- 來撰寫第一個 Hello World 吧!


逐步解說:在 Windows Forms 中建立簡單的 WCF 服務

 逐步解說:在 Windows Forms 中建立簡單的 WCF 服務

--


Calculator Sample in WCF using VB.Net

 Calculator Sample in WCF using VB.Net

--

2023年8月31日 星期四

windows ms-dos 列印文件及圖

 print /d:COM1 'file path'

type d:\abc.txt > COM1

type d:\abc.txt > lpt1

--

share your network printer, even though you will use it yourself

then use this command

net use lpt1: \\ownpcname\printersharename

now use this command again:

type d:\abc.txt > lpt1

Printing to a network Thermal printer

         Public Sub SendViaTCP(ByVal whatIP As String, ByVal whatPort As Integer, ByVal whatToSend As String)

            Dim tcpSender As TcpClient = New TcpClient()

            tcpSender.SendBufferSize = 4096

            tcpSender.Connect(whatIP, whatPort)

            If tcpSender.Connected = False Then

                MessageBox.Show("Not connected")

                tcpSender.Close()

                Exit Sub

            End If


            Dim nStream As NetworkStream = tcpSender.GetStream()

            If nStream.CanWrite = True Then

                Dim SendBytes As [Byte]() = System.Text.Encoding.ASCII.GetBytes(whatToSend)

                nStream.Write(SendBytes, 0, SendBytes.Length)

                nStream.Flush()

            End If

            System.Threading.Thread.Sleep(500)


            nStream.Close()

            tcpSender.Close()

        End Sub


在 Visual Basic 中接收來自序列埠的字串

 如何:在 Visual Basic 中接收來自序列埠的字串

--

Function ReceiveSerialData() As String

    ' Receive strings from a serial port.

    Dim returnStr As String = ""


    Dim com1 As IO.Ports.SerialPort = Nothing

    Try

        com1 = My.Computer.Ports.OpenSerialPort("COM1")

        com1.ReadTimeout = 10000

        Do

            Dim Incoming As String = com1.ReadLine()

            If Incoming Is Nothing Then

                Exit Do

            Else

                returnStr &= Incoming & vbCrLf

            End If

        Loop

    Catch ex As TimeoutException

        returnStr = "Error: Serial Port read timed out."

    Finally

        If com1 IsNot Nothing Then com1.Close()

    End Try


    Return returnStr

End Function

2023年8月2日 星期三

vbnet 判斷閏年

     Private Sub CheckLeapYear(ByVal Int_Year As Integer)

        Dim Boo_LeapYear As Boolean

        Boo_LeapYear = Date.IsLeapYear(Int_Year)

        If Boo_LeapYear Then

            MessageBox.Show(Int_Year & "閏年")

        Else

            MessageBox.Show(Int_Year & "不是閏年")

        End If

    End Sub

2023年6月27日 星期二

Acessando arquivos DBF com C# e VB .NET

 

.NET - Acessando arquivos DBF com C# e VB .NET

--


Declare os seguintes namespaces no formulário:


Imports System.Data.Odbc

Imports System.Data


No evento Click do botão inclua o código abaixo:


 Private Sub btnDBF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDBF.Click


        Dim oConn As New OdbcConnection()

        oConn.ConnectionString = "Driver={Microsoft dBase Driver (*.dbf)};SourceType=DBF;SourceDB=c:\dados\;Exclusive=No; _

                                                Collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;"

        oConn.Open()

        Dim oCmd As OdbcCommand = oConn.CreateCommand()

        oCmd.CommandText = "SELECT * FROM c:\dados\arqDBF.dbf"

        Dim dt As New DataTable()

        dt.Load(oCmd.ExecuteReader())

        oConn.Close()


        DataGridView1.DataSource = dt


    End Sub




Podemos obter o mesmo resultado usando provedor OleDb , neste caso usamos o provedor OleDb:


Imports System.Data.OleDb

Imports System.Data


Substitua o código do evento Click do botão de comando pelo código abaixo:


Dim oConn As New OleDbConnection()

oConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\dados;Extended Properties=dBASE IV;"


oConn.Open()

Dim oCmd As OleDbCommand = oConn.CreateCommand()

oCmd.CommandText = "SELECT * FROM c:\dados\arqDBF.dbf"

Dim dt As New DataTable()

dt.Load(oCmd.ExecuteReader())

oConn.Close()

dataGridView1.DataSource = dt


VBNET InsertRow DBF

 Private Sub InsertRow(ByVal Field1 As String, ByVal Field2 As String, ByVal Field3 As String)

        'see above 

        'here you would set what Typ of Data

        ' I just used Field1 to 3 as a String


        Dim con As OleDbConnection

        Dim dBaseFile As String


        dBaseFile = "TestData.dbf"

        Try

            con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties=dBASE IV;")


            'Create a new instance of the command object

            Using cmd As OleDbCommand = New OleDbCommand("INSERT INTO " & dBaseFile & " ([Field1], [Field2], [Field3]) VALUES (@f1, @f2, @f3)", con)

                'Parameterize the query

                With cmd.Parameters

                    .AddWithValue("@f1", Field1)

                    .AddWithValue("@f2", Field2)

                    .AddWithValue("@f3", Field3)

                End With

                con.Open()

                cmd.ExecuteNonQuery()

                con.Close()

            End Using

        Catch ex As Exception

            Console.WriteLine(ex.Message)

        Finally

            If con IsNot Nothing Then

                If con.State = ConnectionState.Open Then

                    con.Close()

                End If

                con.Dispose()

            End If

        End Try

    End Sub


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

'fill Textboxes and ADD Datarow

        InsertRow(Field1:=TextBox1.Text, Field2:=TextBox2.Text, Field3:=TextBox3.Text)

    End Sub


Using .dbf database in vb.net

 Imports System.Data.OleDb


Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim strSql As String

        strSql = "Select * From TestData.dbf"

        Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties=dBASE IV;")

        Dim cmd As OleDbCommand = New OleDbCommand(strSql, con)

        con.Open()

        Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)

        Dim myDataSet As DataSet = New DataSet()

        myDA.Fill(myDataSet, "MyT")

        Dgv.DataSource = myDataSet.Tables("MyT").DefaultView

        con.Close()

        con = Nothing

    End Sub

End Class

DATAGRIDVIEW載入DBF檔 (VB.NET)

 DBF檔請先匯出成dbase IV 格式



Dim cnn As OleDb.OleDbConnection

cnn = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\POLLYPRO\DATA\NSAMPLE;Extended Properties=DBASE IV;")

Dim da As New OleDbDataAdapter("Select * From test.DBF", cnn)

Dim ds As New DataSet

da.Fill(ds)

GridView1.DataSource = ds.Tables(0)


VB.Net 使用 dBase / FoxPro 資料庫

 VB.Net 如何存取 xBase / FoxPro 資料庫


<< 使用OleDb >>


Imports System.Data.OleDb


Dim strCn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _


"Data Source=C:\DBF檔案所在資料夾;" & _


"Extended Properties=dBASE IV;" & _


"User ID=Admin;Password=;"


Dim strQry As String = "Select * From 某某.dbf"


Dim cn As New OleDbConnection(strCn)


Dim da As New OleDbDataAdapter(strQry, cn)


Dim ds As New DataSet


da.Fill(ds)


DataGridView1.DataSource = ds.Tables(0)


PS : ConnectionString 的 Extended Properties 可為 dBASE IV 或 dBASE 5.0 或 dBASE III。


也可以是 FoxPro 2.0 、 FoxPro 2.5 、 FoxPro 2.6 、 FoxPro 3.0


' ================================================================


<< 使用ODBC >>


Imports System.Data.Odbc


Dim strCn As String = "DRIVER={Microsoft dBase Driver (*.dbf)};dbq=C:\DBF檔案所在資料夾"


Dim strQry As String = "Select * From 某某.DBF"


Dim cn As New OdbcConnection(strCn)


Dim da As New OdbcDataAdapter(strQry, cn)


Dim ds As New DataSet


da.Fill(ds)


DataGridView1.DataSource = ds.Tables(0)


PS : ConnectionString 的 Driver 可為 [ODBC 資料來源管理員] 中所提供的 驅動程式。


如:


"DRIVER={Microsoft dBase Driver (*.dbf)};dbq=C:\DBF檔案所在資料夾"


"DRIVER={Microsoft dBase VFP Driver (*.dbf)};dbq=C:\DBF檔案所在資料夾"


"DRIVER={Microsoft FoxPro Driver (*.dbf)};dbq=C:\DBF檔案所在資料夾"


"DRIVER={Microsoft FoxPro VFP Driver (*.dbf)};dbq=C:\DBF檔案所在資料夾"


"DRIVER={Microsoft Visual FoxPro Driver (*.dbf)};dbq=C:\DBF檔案所在資料夾"


xBase 或 FoxPro 資料庫,只要有 ODBC Driver,皆可使用相同方式來連線存取。


2023年6月15日 星期四

檢查 form 是否已開

 For Each frm As Form In Application.OpenForms

    If frm.Name = Form1.Name Then

       MessageBox.Show("Opened")

    End If

Next

2023年5月30日 星期二

PrintDocument print to file

  printDoc.PrinterSettings.PrinterName="Microsoft Print to PDF"

 printDoc.PrinterSettings.PrintToFile = True

 printDoc.PrinterSettings.PrintFileName =  "c:\1.pdf"


2023年5月14日 星期日

ASP.NET Core 實作開發

 ASP.NET Core 實作開發

請參考來源,很詳細的實作


POS 系統 2023 前台系統

重新開發 Winows POS 系統 2023 前台系統(網路版) 已完成95%

後續將繼續重新開發 Windows POS 系統 2023 後台系統(網路版)

現階段將先把 Windows 平台的 POS 系統完成

未來將開發 WebAPP POS 版本 (雲端版本)

系統結構將能使用在各種平台(Windows/WebAPP)  

WebAPP 即可在 Windows/Linux/Android/IOS 等裝置平台上操作使用

歡迎有興趣洽談 池龍工作室

---

為什麼要重新開發?

因為以前都整合前後台一起,現在重新開發的版本會拆開分成:

前台 , 後台 , 資料交換 

另一個重點,是要和別公司合作;所以不打算用現行已在市面運作的POS系統!

用全新的系統合作,較不影響現行的客戶

---








2023年5月9日 星期二

tcpClient.BeginConnect

 c#:

public bool Test()

{

     using (var tcp = new TcpClient())

     {

         var c = tcp.BeginConnect(IPAddress.Parse("8.8.8.8"), 8080, null, null);

         var success = c.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(1));


         if (!success)

         {

             Console.WriteLine("Before cleanup");

             tcp.Close();

             tcp.EndConnect(c);

             Console.WriteLine("After cleanup");

             throw new Exception("Failed to connect.");

         }

     }


     return true;

}




vbnet:

Public Function Test() As Boolean

Using tcp As Object = New TcpClient()

Dim c As Object = tcp.BeginConnect(IPAddress.Parse("8.8.8.8"), 8080, Nothing, Nothing)

Dim success As Object = c.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(1))


If Not success Then

Console.WriteLine("Before cleanup")

tcp.Close()

tcp.EndConnect(c)

Console.WriteLine("After cleanup")

Throw New Exception("Failed to connect.")

End If

End Using


Return True

End Function


====

調整用法:

 Public Function Test() As Boolean

        Using tcp As Object = New TcpClient()

            Dim c As Object = tcp.BeginConnect(IPAddress.Parse("192.168.1.78"), 1435, Nothing, Nothing)

            Dim success As Object = c.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(1))

            If Not success Then

                tcp.Close()

                Return False

            End If

        End Using

        Return True

    End Function


2023年5月8日 星期一

解決問題 ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION

 解决Chrome 下载带半角分号出现net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION的问题

方式一:添加双引号

Response.AddHeader("content-disposition", "attachment; filename=\"" + FileName + "\"")


方式二:替换掉文件的半角分号

var FileName = "www.kzwr.com,酷站网软".Replace(",", "")

Response.ContentType = "application/pdf"

Response.AddHeader("content-disposition", "attachment; filename=" & FileName)    

Response.BinaryWrite(myPDF)


更改IIS上傳下載檔案限制

 IIS 6.0預設的上傳檔案大小只有200KB喔!


以記事本開啟 C:\windows\sytem32\inetserv\metabase.xml 上傳限制: 找尋 AspMaxRequestEntityAllowed 字串 將 204800 (200K) 修改成你要的數字 下載限制: 找尋 AspBufferingLimit 字串 預設 4MB ,將它修改成你要的數字==============================================

在IIS7的ASP檔案上傳下載的限制設定如下:

進入伺服器管理員–>IIS管理員–>站台–>ASP(開啟功能)–>限制內容

其中的

[要求實體的上限]:4194304(bytes)  –>即是允許下載檔案的大小限制

[回應緩衝處理限制]:3000000(bytes)  –>即是允許上傳檔案的大小限制

依實際需求修改大小(bytes),並可正常上傳及下載.

2023年5月4日 星期四

codeguru 網站

 codeguru

----

CodeGuru 涵蓋與 Microsoft 相關的軟件開發、移動開發、數據庫管理和 Web 應用程序編程相關的主題。 除了教程序員如何使用 Microsoft 相關語言和框架(如 C# 和 .Net)進行編碼的教程和操作方法外,我們還發布了有關軟件開發工具的文章、最新的開發人員新聞以及對項目經理的建議。 Microsoft Azure 等雲服務和 SQL Server 和 MSSQL 等數據庫選項也經常包含在內。


ML.NET 文件

----

2023年5月3日 星期三

gridview search filter

 Filtering In Datagridview In Vb.Net And Also In C#  參考完整的code

其他簡易處理方法:

#1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

       ElementaryDataGridView.DataSource = ElementaryBindingSource

       dtTableGrd = ElementaryDataGridView.DataSource

   End Sub


   Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox1.TextChanged

       dtTableGrd.DefaultView.RowFilter = "SchoolName Like '%" & TextBox1.Text & "%'"

   End Sub


#2

Public Class Form1

    Private dtTableGrd As DataTable

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        DataGridView1.DataSource = EmployeeProfileBindingSource 

        dtTableGrd = EmployeeProfileBindingSource

    End Sub


    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged

        dtTableGrd.DefaultView.RowFilter = "Employee_Fname Like '%" & TextBox1.Text & "%'"

    End Sub

End Class


#3

BindingSource.Filter = String.Format("{0} = '{1}'", "column name here", "filter value here")


#4

    Private Sub txt_search_TextChanged(sender As System.Object, e As System.EventArgs) Handles txt_search.TextChanged

        BindingSource1.Filter = String.Format("{0} LIKE '{1}%'", "user", txt_search.Text)


        BindingSource1.Sort = "user ASC"

    End Sub


    Private Sub txt_search_Validated(sender As System.Object, e As System.EventArgs) Handles txt_search.Validated

        If txt_search.Text = String.Empty Then

            BindingSource1.RemoveFilter()

        Else

            BindingSource1.Filter = String.Format("{0} = '{1}'", "user", txt_search.Text)


            BindingSource1.Sort = "user ASC"

        End If

    End Sub



 Check all and Uncheck all CheckBox in DataGridView in Windows Application using C# and VB.Net

---

aspsnippets Home

網站內也有更多的相關技文參考


2023年4月26日 星期三

SQL Server的最新更新和版本歷程記錄

 SQL Server的最新更新和版本歷程記錄

---

非常詳細的所有 MS-SQL 2008 到 MS-SQL 2022 核心版本記錄表

不知道電腦到底安裝了哪一版本,可以到該網址內查看記錄表


2023年4月12日 星期三

vb.net keyboard hook example

 Imports System.Runtime.InteropServices

Public Class Form1

    Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As KeyboardProc, ByVal hmod As IntPtr, ByVal dwThreadId As Integer) As IntPtr

    Private Declare Function CallNextHookEx Lib "user32" (ByVal hhk As IntPtr, ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr

    Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hhk As IntPtr) As Boolean


    Private Delegate Function KeyboardProc(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr


    Private Const WM_KEYDOWN As Integer = &H100

    Private Const WH_KEYBOARD_LL As Integer = 13


    Private hHook As IntPtr


    Private Function KeyboardProcHandler(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr

        If nCode >= 0 AndAlso wParam = WM_KEYDOWN Then

            Dim vkCode As Integer = Marshal.ReadInt32(lParam)

            MessageBox.Show("Key Code: " & vkCode)

        End If

        Return CallNextHookEx(hHook, nCode, wParam, lParam)

    End Function


    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        hHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf KeyboardProcHandler, IntPtr.Zero, 0)

    End Sub


    Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing

        UnhookWindowsHookEx(hHook)

    End Sub

End Class

VBNET 攔截key值(二)

 Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, _

                                           ByVal keyData As System.Windows.Forms.Keys) _

                                           As Boolean


    If msg.WParam.ToInt32() = CInt(Keys.Enter) Then

        SendKeys.Send("{Tab}")

        Return True

    End If

    Return MyBase.ProcessCmdKey(msg, keyData)

End Function



Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean

    Dim keyCode As Keys = CType(msg.WParam, IntPtr).ToInt32

    Const WM_KEYDOWN As Integer = &H100


    If msg.Msg = WM_KEYDOWN AndAlso keyCode = Keys.Enter _

     AndAlso Me.ActiveControl.GetType.Name = "TextBox" Then

        Me.SelectNextControl(Me.ActiveControl, True, True, False, True)

        Return True


    End If

    Return MyBase.ProcessCmdKey(msg, keyData)



End Function

2023年4月5日 星期三

VBNET 攔截key值

 Public Class Form1

    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Integer) As Integer


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        If GetAsyncKeyState(Keys.L) Then

            MsgBox("Tada!")

        End If

    End Sub

End Class

2023年3月5日 星期日

緩衝集區裡沒有足夠的可用記憶體

DBCC MEMORYSTATUS



釋放MSSQL Server Cache (緩衝集區裡沒有足夠的可用記憶體)


當出現"緩衝集區裡沒有足夠的可用記憶體"此項錯誤時,可嘗試使用以下指令釋放快取記憶體;或是於程式中固定一段時間執行此三個Query



操作指令(適用2005,2008):

DBCC FREESYSTEMCACHE('all')

DBCC FREESESSIONCACHE

DBCC FREEPROCCACHE WITH NO_INFOMSGS


***********************


DBCC FREEPROCCACHE --清除存儲過程相關的緩存 

DBCC FREESESSIONCACHE --會話緩存 

DBCC FREESYSTEMCACHE('All') --系統緩存 

DBCC DROPCLEANBUFFERS --所有緩存

2023年3月3日 星期五

Visual Studio 參考檔 dll 找不到解法方法

 一些舊專案加上舊的OS 上開發

轉到新的OS+VS新的版本開發

會造成在編譯(發行)中,有DLL遺失問題

在Web 開發,會將所有的DLL 放在Bin目錄內

將遺失列出的dll 從新指定在Bin內即可成功編譯(發行)

列:

..\..\..\..\..\..\Program Files (x86)\Microsoft Web Tools\Packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll

這樣的路徑會指到D: 且OS已不存在
改成:
D:\xx\Bin\Microsoft.AspNet.Identity.Core.dll
即可成功



2023年2月14日 星期二

RestartService

 Public Shared Function RestartService(ByVal ServiceName As String) As Boolean

    Dim mySC As ServiceProcess.ServiceController

    Try

        mySC = New ServiceProcess.ServiceController(ServiceName)

        mySC.Stop()

        mySC.Start()

        Return mySC.Status = ServiceProcess.ServiceControllerStatus.Running

    Catch

        Return False

    End Try

End Function



' restart without bothering about success or failure

RestartService("MSSQLSERVER")


'or like this if you are too concerned ;)

If RestartService("MSSQLSERVER") Then

    MsgBox("Service restarted")

Else

    MsgBox("Unable to restart the service.")

End If


----------------------------------------

@ECHO OFF


net stop ServiceName

net start ServiceName


2023年2月13日 星期一

delay 的方法

  Sub delay(ByVal delay_ms As Integer)

        Dim tspan As New TimeSpan

        Dim tstart = Now

        While tspan.TotalMilliseconds < delay_ms

            tspan = Now - tstart

            Application.DoEvents()

        End While

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Label1.Text = "Hello"

        delay(100) 'leaks 572 ns every 10 ms

        Label1.Text = "Salut"

    End Sub


2023年1月9日 星期一

ProcessCmdKey

 Public Class Form1


    Protected Overrides Function ProcessCmdKey(ByRef msg As Message, keyData As Keys) As Boolean

        Select Case keyData

            Case (Keys.F10 Or Keys.Shift Or Keys.Control)

                MessageBox.Show("You pressed Shft+Ctrl+F10.")

                Return True

            Case (Keys.F10 Or Keys.Control)

                MessageBox.Show("You pressed Ctrl+F10.")

                Return True

            Case Keys.F10

                MessageBox.Show("You pressed F10.")

                Return True

        End Select


        Return MyBase.ProcessCmdKey(msg, keyData)

    End Function


End Class




Option Strict On


Public Class Form1


    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (Me.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - (Me.Height / 2)))

        Me.KeyPreview = True

    End Sub


    Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown

        If e.KeyCode = Keys.F10 Then

            e.Handled = True

            Button2_Click(Me, Nothing)

        End If

        If e.Control AndAlso e.KeyCode = Keys.B Then

            e.Handled = True

            Button2_Click(Me, Nothing)

        End If

    End Sub


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Button2.Text = ChrW(38) & "Follow"

    End Sub


    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        MessageBox.Show("Button2 selected.")

    End Sub


End Class

MS-SQL刪除帳號

 SELECT * FROM INFORMATION_SCHEMA.SCHEMATA


將帳號佔用的權限轉移到dbo

alter authorization on schema::[db_securityadmin] To [dbo]