10/20/2013

Public Sub ConnectionSql()

        Dim Conn As SqlConnection = New SqlConnection
        Dim IP As String = "192.000.XXX.XXX"
        Dim DBName As String = "Store"
        Dim Username As String = "MyAdmin"
        Dim Password As String = "password"


        Try

            Conn.Close()
            With Conn
                If .State = ConnectionState.Open Then .Close() : MsgBox("Can not connect to database server !") : Exit Sub
                .ConnectionString = "Data Source=" & IP & ";Initial Catalog=" & DBName & ";Persist Security Info=True;User ID=" & Username & ";Password=" & Password & ""
                .Open()
            End With

        Catch ex As Exception
            MsgBox("Can not connect to database server !")
         End Try


End Sub

Posted on Sunday, October 20, 2013 by nuyingnaja

9/22/2013

ค้นหา  Column ใน DataTable

If Not dtLawWord.Columns.Contains("ID") Then
                MessageBox.Show("Can not Find Columns ID")
End If

Posted on Sunday, September 22, 2013 by nuyingnaja

9/19/2013


Imports Microsoft.Office.Interop.Word
Imports Microsoft.Office.Interop
Imports Microsoft.Office

Public Class classWord

    Public Sub GetWord()


        Dim WdApp As New Application

        Dim WdDoc As Word.Document

        WdDoc = WdApp.Documents.Open("D:\text.doc")

        Dim rStart, rStop As Integer

        rStart = 100

        rStop = 200

        WdDoc.Range(Start:=rStart, End:=rStop).Delete()

        WdDoc.Save()

        WdDoc.Close()

        WdDoc = Nothing

        WdApp.Quit()

        WdApp = Nothing

    End Sub

End Class

Posted on Thursday, September 19, 2013 by nuyingnaja

9/17/2013


For Each oRow As DataGridViewRow In DataGridView1.Rows

            TextBox1.Text = oRow.Cells(1).Value

Next

Posted on Tuesday, September 17, 2013 by nuyingnaja


Private Sub CopyFileToFolder(ByVal FileName As String, ByVal FileNameNew As String)

        File.Copy(FileName, FileNameNew, True)

End Sub

Posted on Tuesday, September 17, 2013 by nuyingnaja


Private Sub CreatFolder(ByVal pathName As String)

        If Not System.IO.Directory.Exists(pathName) Then        ' ถ้าไม่มี Directory name นี้
            My.Computer.FileSystem.CreateDirectory(pathName)  ' ก็จงสร้าง Directory name นี้
        End If

End Sub

Posted on Tuesday, September 17, 2013 by nuyingnaja

9/16/2013


Dim i As Integer = DataGridView1.Rows.Count - 1

For irow = 0 To DataGridView1.Rows.Count - 1

            ' if Row is Selete Check Box is Delete row
            If DataGridView1.Rows.Item(i).Cells(0).Value = True Then

                DataGridView1.Rows.RemoveAt(i)

            End If
            i -= 1

Next

Posted on Monday, September 16, 2013 by nuyingnaja