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()

No comments: