Wednesday, November 23, 2011

VB.NET Access connectionstring with database password & server.mappath

Imports System.Data.OleDb
Imports System.Data


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=" & Server.MapPath("ivashi2011.mdb") & ";Jet OLEDB:Database Password=k12i07s2002s;"

        oConn = New OleDbConnection(sConn)
        sComm = "select * FROM mainmaster"
        oComm = New OleDbDataAdapter(sComm, oConn)
        oComm.Fill(oDataSet, "mainmaster")

        DataGrid1.DataSource = oDataSet.Tables("mainmaster").DefaultView
        DataGrid1.DataBind()

VB.NET OPEN any Type of file

Imports System.Diagnostics

 Dim p As New System.Diagnostics.Process
        Dim s As New System.Diagnostics.ProcessStartInfo("d:\report1.rpt")
        s.UseShellExecute = True
        s.WindowStyle = ProcessWindowStyle.Normal
        p.StartInfo = s
        p.Start()

Tuesday, November 22, 2011

VB.NET READ TEXT FILE

Imports System.IO.File

Dim fileText As String = My.Computer.FileSystem.ReadAllText("c:\sample.txt")
        Console.WriteLine(fileText)
OR
        Button1.Text = System.IO.File.ReadAllText("c:\sample.txt")