Wednesday, October 27, 2010

VB.NET (Wndows) Fill Datagrid with Access table

Imports System.Data.OleDb

Dim oConn As OleDbConnection
        Dim oComm As OleDbDataAdapter
        Dim sConn As String
        Dim sComm As String
        Dim oDataSet As New DataSet
        sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\avs.mdb;Persist Security Info=False"
     
        oConn = New OleDbConnection(sConn)
        sComm = "select distinct party from avst"
        oComm = New OleDbDataAdapter(sComm, oConn)
        oComm.Fill(oDataSet, "avst")

        DataGridparty.DataSource = oDataSet.Tables("avst").DefaultView
        DataGridparty.Refresh()

Tuesday, October 12, 2010

VB.NET Creating Zip File

 //Imports System.IO

Dim emptyZip As Byte() = {80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
        Dim oApp As Object

        'Destination Zip File Name Here
        File.WriteAllBytes("c:\avs.zip", emptyZip)
        oApp = CreateObject("Shell.Application")

        'Source File Name
        oApp.Namespace("c:\avs.zip").CopyHere("c:\avs.mdb")
        MsgBox("Zipped..")