Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ช่วยทีครับถ้าผมจะเอาโค๊ดแบบนี้ มาทำใส่ progressBar กะ backgroundWorker ต้องทำยังไงครับ



 

ช่วยทีครับถ้าผมจะเอาโค๊ดแบบนี้ มาทำใส่ progressBar กะ backgroundWorker ต้องทำยังไงครับ

 



Topic : 110495



โพสกระทู้ ( 4,436 )
บทความ ( 23 )



สถานะออฟไลน์
Facebook



Code (C#)
public static System.Collections.Generic.List<string> GetFilesRecursive(string initial,string Exp)
        {
            System.Collections.Generic.List<string> result = new System.Collections.Generic.List<string>();
            System.Collections.Generic.Stack<string> stack = new System.Collections.Generic.Stack<string>();
            stack.Push(initial);
            while ((stack.Count > 0))
            {
                string dir = stack.Pop();
                result.AddRange(System.IO.Directory.GetFiles(dir, Exp));
                string directoryName = null;
                foreach (string directoryName_loopVariable in System.IO.Directory.GetDirectories(dir))
                {
                    directoryName = directoryName_loopVariable;
                    stack.Push(directoryName);
                }
            }
            return result;
        }




Tag : .NET, Win (Windows App), C#, Windows







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-08-08 11:53:46 By : lamaka.tor View : 1148 Reply : 7
 

 

No. 1

Guest


https://www.thaicreate.com/dotnet/forum/099705.html






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-08-14 10:14:28 By : ห้ามตอบเกินวันละ 2 กระทู้
 


 

No. 2

Guest


ตอบความคิดเห็นที่ : 1 เขียนโดย : ห้ามตอบเกินวันละ 2 กระทู้ เมื่อวันที่ 2014-08-14 10:14:28
รายละเอียดของการตอบ ::
https://www.thaicreate.com/dotnet/forum/099705.html


เขียนโปรแกรมห่วยฯ SourceCode ห่วยฯ อันนี้ผมหมายถึงตัวของคุณเอง)

อาจเป็นไปได้ว่าผมคิดผิด และอาจเป็นไปได้ว่าผมคิดถูก...
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-08-15 14:07:45 By : หน้าฮี
 

 

No. 3



โพสกระทู้ ( 611 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 2 เขียนโดย : หน้าฮี เมื่อวันที่ 2014-08-15 14:07:45
รายละเอียดของการตอบ ::
เขียนโปรแกรมห่วยฯ SourceCode ห่วยฯ (อันนี้ผมหมายถึงตัวของคุณเอง)
อาจเป็นไปได้ว่าผมคิดผิด และอาจเป็นไปได้ว่าผมคิดถูก...


... ประกาศ ENUM เหมือนผมไปรบที่เกาหลี (ลห ... ี...)
...
...



ปล. สระอี มันขยับไปมาระหว่าง ลอลิงและหอหีบ งงเหมือนกันว่ามันขยับได้อย่างไร


ประวัติการแก้ไข
2014-08-15 14:15:42
2014-08-15 14:17:27
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-08-15 14:14:00 By : หน้าฮี
 


 

No. 4



โพสกระทู้ ( 611 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 1 เขียนโดย : ห้ามตอบเกินวันละ 2 กระทู้ เมื่อวันที่ 2014-08-14 10:14:28
รายละเอียดของการตอบ ::
รบกวนถามนิดหนึ่ง เคยใช้ DbFactory Class ไหมครับ มีข้อจำกัดอะไรบ้าง?



เหตุผล ไม่เคยใช้แต่ต้องการความสะดวก ในกรณีที่เปลี่ยน RDBMS แต่ไม่รู้ว่ามันจะทำงานช้าลง เยอะไหม?
(ผมไม่มีเวลาทดสอบในสภาพแวดล้อมจริง)

Code (VB.NET)
'Create Date : 2014-08-16 สดสดร้อนร้อน

Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Text

Imports System.Data
Imports System.Data.Common
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.Data.OracleClient
Imports MySql.Data.MySqlClient

Public Class DbProvider

    Private Shared sqlFactory As DbProviderFactory
    Private Shared oracleFactory As DbProviderFactory
    Private Shared mysqlFactory As DbProviderFactory
    Private Shared oledbFactory As DbProviderFactory
    Private Shared sqliteFactory As DbProviderFactory
    Private Shared db2Factory As DbProviderFactory
    Private Shared vfpFactory As DbProviderFactory 'Visual FoxPro Provider
    Private Shared unknowFactory As DbProviderFactory

    Private Shared providerName As String = PubConstant.ProviderName 'declare in web.config

    Public Shared Function GetFactory(Optional ByVal pvdStr As String = "") As DbProviderFactory
        If pvdStr = String.Empty Then
            pvdStr = providerName
        End If
        Select Case pvdStr
            Case "System.Data.SqlClient"
                If sqlFactory Is Nothing Then
                    sqlFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return sqlFactory
            Case "System.Data.OracleClient"
                If oracleFactory Is Nothing Then
                    oracleFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return oracleFactory
            Case "System.Data.MySqlClient"
                If mysqlFactory Is Nothing Then
                    mysqlFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return mysqlFactory
            Case "System.Data.OleDb"
                If oledbFactory Is Nothing Then
                    oledbFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return oledbFactory
            Case "System.Data.DB2Client"
                If db2Factory Is Nothing Then
                    db2Factory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return db2Factory
            Case "System.Data.VFPClient" 'FastDBClient (www.codeplex.com)
                If vfpFactory Is Nothing Then
                    vfpFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return vfpFactory
            Case Else
                If unknowFactory Is Nothing Then
                    unknowFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return unknowFactory
        End Select
    End Function

    Public Shared Function CreateConnection(Optional ByVal pvdStr As String = "") As DbConnection
        If pvdStr = String.Empty Then
            pvdStr = providerName
        End If
        Dim cn As DbConnection = DbProvider.GetFactory(pvdStr).CreateConnection()
        cn.ConnectionString = PubConstant.ConnectionString 'declare in web.config
        Return cn
    End Function

    Public Function BuildParameter(ByVal pName As String, pValue As Object, Optional ByVal pvdStr As String = "") As DbParameter
        Dim dbParam As DbParameter = Nothing
        If pvdStr = String.Empty Then
            pvdStr = providerName
        End If
        Select Case pvdStr
            Case "System.Data.SqlClient"
                dbParam = New SqlParameter() With {.ParameterName = pName, .Value = pValue}
            Case "System.Data.OracleClient"
                dbParam = New OracleParameter() With {.ParameterName = pName, .Value = pValue}
            Case "System.Data.MySqlClient"
                dbParam = New MySqlParameter() With {.ParameterName = pName, .Value = pValue}
            Case "System.Data.OleDb"
                dbParam = New OleDbParameter With {.ParameterName = pName, .Value = pValue}
            Case "System.Data.DB2Client"
                '
            Case "System.Data.VFPClient" 'FastDBClient (www.codeplex.com)
                '
            Case Else
                'Not Implement yet.
        End Select
        Return dbParam
    End Function

    Public Shared Function FixedParam(ByVal s As String, Optional ByVal pvdStr As String = "") As String
        If pvdStr = String.Empty Then
            pvdStr = providerName
        End If
        Select Case pvdStr
            Case "System.Data.SqlClient", "System.Data.MySqlClient"
                s = s.Replace("@_@", "@")
            Case "System.Data.OracleClient"
                s = s.Replace("@_@", ":")
            Case "System.Data.OleDb", "System.Data.VFPClient"
                s = s.Replace("@_@", "?")
            Case "System.Data.DB2Client"
                '
            Case "System.Data.VFPClient" 'FastDBClient (www.codeplex.com)
                '
            Case Else
                'Not Implement yet.
        End Select
        Return s
    End Function

    'ทดสอบ
    Public Sub Test()
        Using cn As DbConnection = CreateConnection()
            Using cmd As DbCommand = cn.CreateCommand()
                cmd.CommandType = CommandType.Text
                cmd.CommandText = FixedParam("Insert into Student Values(@_@StudentCode, @_@StudentName, @_@Age)")
                Dim lstParam As New List(Of DbParameter) From
                    {BuildParameter("StudentCode", "0001"),
                     BuildParameter("StudentName", "ตัวเล็ก หน้าอกใหญ่"),
                     BuildParameter("Age", 18)
                    }
                cmd.Parameters.Clear()
                cmd.Parameters.Add(lstParam)
                cn.Open()
                cmd.ExecuteNonQuery()
            End Using
        End Using
    End Sub
End Class

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-08-16 13:20:55 By : หน้าฮี
 


 

No. 5



โพสกระทู้ ( 611 )
บทความ ( 0 )



สถานะออฟไลน์


ข้อจำกัดของ DbProviderFactory (.NET 4.0)
1. Connection ไม่สามารถสร้าง DataAdaptor ได้โดยตรง (CreateDataAdaptor)
http://stackoverflow.com/questions/3488962/how-to-create-a-dbdataadapter-given-a-dbcommand-or-dbconnection

อันนี้ปกติ (ลอง Select ข้อมูลแล้วความเร็วไม่แตกต่างกัน)
Code (VB.NET)
Dim dtReturn As New DataTable()
Using Conn As New SqlConnection("Data Source = ServerName;...")
    Using da As New SqlDataAdapter("Select * From Table...", Conn)
        da.Fill(dtReturn)
    End Using
End Using


อันนี้อ้อมโลก (ลอง Select ข้อมูลแล้วความเร็วไม่แตกต่างกัน)
Code (VB.NET)
Dim dtReturn As New DataTable()
Using Conn As DbConnection = DbProvider.CreateConnection()
    Using da As DbDataAdapter = DbProvider.GetFactory().CreateDataAdapter()
        Using cmd As DbCommand = Conn.CreateCommand()
            cmd.CommandText = "Select * From Table..."
            da.SelectCommand = cmd
            da.Fill(dtReturn)
        End Using
    End Using
End Using




2. ยังไม่พบ แต่คิดว่าน่าจะมีอีกเยอะเลย
3. เหมือนข้อที่ 2.
...
...
...


ปล. โดยภาพรวมถ้าทำงานได้ดีระดับหนึ่งและประสิทธิภาพลดลงไป 20-30% ก็ถือว่าคุ้มค่า (แลกกับความสะดวก)


ประวัติการแก้ไข
2014-08-17 09:30:50
2014-08-17 09:31:24
2014-08-17 09:32:42
2014-08-17 09:42:24
2014-08-17 09:53:51
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-08-17 09:28:30 By : หน้าฮี
 


 

No. 6



โพสกระทู้ ( 611 )
บทความ ( 0 )



สถานะออฟไลน์


Code (VB.NET)
Private Shared providerName As String = PubConstant.ProviderName


ตัวแปร Global/Public ผมจะประกาศเอาไว้ที่นี่ทั้งหมดที่เดียว
เหตุผล : ผมอายุมากแล้ว(แก่แล้ว) ถ้าให้ต้องจำอะไรเยอะฯ มันจำไม่ได้ครับ (ถ้าเป็นระบบงานเล็กฯจะทำอย่างไรก็ได้)

Class PubConstant
Code (VB.NET)
Imports System.ComponentModel
Imports System.Configuration

Public Class PubConstant

    Sub New()
    End Sub

    Public Enum Language
        <Description("th-TH")> _
        Thai
        <Description("en-US")> _
        English
        <Description("jp-JP")> _
        Japan
        <Description("lao-LAO")> _
        Lao
    End Enum

    Public Enum SearchOption
        Equal
        NotEqual
        MoreThan
        LessThan
        MoreThanOrEqual
        LessThanOrEqual
        Between
        StartWith
        EndWith
        Contain
    End Enum

    Public Enum RightsOption
        View
        Insert
        Update
        Delete
        Approved
        Print
        Export
    End Enum

    '
    'อ่านจากจาก web.config/app.config
    '
    Public Shared ReadOnly Property GetAppSettingsValue(ByVal key As String) As String
        Get
            Return ConfigurationManager.AppSettings(key)
        End Get
    End Property

    Public Shared ReadOnly Property ProviderName() As String
        Get
            Return GetAppSettingsValue("ProviderName")
        End Get
    End Property

    Public Shared ReadOnly Property ProviderName(ByVal cs As String) As String
        Get
            Return ConfigurationManager.ConnectionStrings(cs).ProviderName
        End Get
    End Property

    Public Shared ReadOnly Property ConnectionString() As String
        Get
            Dim _connectionString As String = ConfigurationManager.AppSettings("ConnectionString")
            Dim IsEncrypt As String = Security.Crypter.DESDecrypt(ConfigurationManager.AppSettings("ConnectionStringEncrypt"))
            If IsEncrypt = "true" Then
                _connectionString = Security.Crypter.DESDecrypt(_connectionString)
            End If
            Return _connectionString
        End Get
    End Property

    Public Shared ReadOnly Property ConnectionString(ByVal cs As String) As String
        Get
            Return ConfigurationManager.ConnectionStrings(cs).ConnectionString
        End Get
    End Property

End Class



ตัวอย่างไฟล์ web.config

Code (XML)
<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!--<sectionGroup name="system.web">
      <section name="sanitizer" requirePermission="false" type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit"/>
    </sectionGroup>-->
  </configSections>
  <connectionStrings>
    <add name="Mssql" connectionString="Data Source=SOMPARN-PC;Initial Catalog=SomparnDB;User ID=sa;Password=9876" providerName="System.Data.SqlClient" />
    <add name="Oracle" connectionString="XXXX" providerName="System.Data.OracleClient"/>
    <add name="MySQL" connectionString="Server=191.168.1.1;Database=myDataBase;Uid=myUsername;Pwd=myPassword;" providerName="MySql.Data.MySqlClient"/>
    <add name="SQlite" connectionString="Data Source= ~/SQLiteDB/Test_DB_V3.s3db;Version=3;UTF8Encoding=True;Password=9876;" providerName="System.Data.SqlLite" />
  </connectionStrings>
  <appSettings>
    <add key="ConnectionStringEncrypt" value="870042BB4DFE7420" />
    <!-- true = 870042BB4DFE7420, false = A154273BF2464F4E -->
    <add key="ConnectionString" value="EB4BE3F2D06F5CC873B2C82C8BC034C04B2F4ABC592AFB46ABC33BF919EE02729742B42202B5B10128131010FB11A0F49BA59AF24FC07A44DA70AC41250923EF045B855B802EAF02769B274B42A00E5D" />
    <add key="providerName" value="System.Data.SqlClient" />
    <add key="RDBMSType" value="MSSQL" />



ประวัติการแก้ไข
2014-08-17 10:06:54
2014-08-17 10:08:09
2014-08-17 10:16:34
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-08-17 09:56:17 By : หน้าฮี
 


 

No. 7



โพสกระทู้ ( 611 )
บทความ ( 0 )



สถานะออฟไลน์


ในอนาคตตั้งใจเอาไว้ว่าจะ
1. ใช้ระบบฐานข้อมูล
FireBird RDBMS เป็นหลัก
เหตุผล: ฟรี ต้นทุนต่ำ แข็งแกร่ง และที่สำคัญ http://www.firebirdsql.org/refdocs/langrefupd21-select.html
------ มี Recursive, CTE, etc.. แจ่มแมวจริงฯครับ
------ มี Rows Explorer เช่น Select Skip 10 From TableXXX แจ๋วจริงฯ

แบบนี้มันก็ทำได้ งงวุ้ย
Code (SQL)
select first 20 skip 80 id, name from People
  order by name asc


Code (SQL)
select strlen(lastname) as len_name, count(*)
  from people
  group by len_name -- งงวุ้ยทำได้อย่างไรว่ะ


------ และอีกเยอะเลยครับ

2. ใช้ VS2010 Version Express เป็นหลัก (แลกกับความน่าเชื่อถือต่ำ)
เหตุผล: ฟรี ต้นทุนต่ำ และอะไรที่ Advance เราไม่ได้ใช้อยู่แล้ว (เทอะทะ)
------ สงสัยไหมว่าทำไมผมถึงต้องใช้ VS2010 (Version ล่าสุด VS2014)
------ กริ้งฯถามว่า Host ของคุณ Support .NET 4.5, 4.51 ไหม?
------ ครับ แต่คุณต้องจ่ายเงินเพิ่ม (เซ็งไปเลยครับ)
------ เป็นแฟนคนจนต้องทนหน่อยน้อง พี่นี้ไม่มีเงินทองมารองรับความลำบาก...


3. ...
...
...
...


Code (VB.NET)
    Public Shared Function GetFactory(Optional ByVal pvdStr As String = "") As DbProviderFactory
        If pvdStr = String.Empty Then
            pvdStr = providerName
        End If
        Select Case pvdStr
            Case "System.Data.SqlClient"
                If sqlFactory Is Nothing Then
                    sqlFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return sqlFactory
            Case "System.Data.OracleClient"
                If oracleFactory Is Nothing Then
                    oracleFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return oracleFactory
            Case "MySql.Data.MySqlClient"
                If mysqlFactory Is Nothing Then
                    mysqlFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return mysqlFactory
            Case "System.Data.OleDb"
                If oledbFactory Is Nothing Then
                    oledbFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return oledbFactory
            Case "System.Data.SQLite"
                If sqliteFactory Is Nothing Then
                    sqliteFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return sqliteFactory
            Case "FirebirdSql.Data.FirebirdClient" 'Version 4.5.0.0 (2014-08-17)
                If firebirdFactory Is Nothing Then
                    firebirdFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return firebirdFactory
            Case "System.Data.DB2Client"
                If db2Factory Is Nothing Then
                    db2Factory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return db2Factory
            Case "System.Data.VFPClient" '(www.codeplex.com)
                If vfpFactory Is Nothing Then
                    vfpFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return vfpFactory
            Case Else
                If unknowFactory Is Nothing Then
                    unknowFactory = DbProviderFactories.GetFactory(pvdStr)
                End If
                Return unknowFactory
        End Select
    End Function



ประวัติการแก้ไข
2014-08-17 11:53:58
2014-08-17 11:56:01
2014-08-17 12:05:04
2014-08-17 12:10:23
2014-08-17 12:19:18
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-08-17 11:48:07 By : หน้าฮี
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยทีครับถ้าผมจะเอาโค๊ดแบบนี้ มาทำใส่ progressBar กะ backgroundWorker ต้องทำยังไงครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่