Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Database.

Database.

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasetutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    v450305
    wrote on last edited by
    #1

    Hi Dear, How to connect MS Access database using ASP.net regards adil

    B 1 Reply Last reply
    0
    • V v450305

      Hi Dear, How to connect MS Access database using ASP.net regards adil

      B Offline
      B Offline
      bayo
      wrote on last edited by
      #2

      Hello Adil, you can use OleDbConnection, for e.g using System.Data.OleDb; //... //... //... OledbConnection conn = new OleDbConnection("your connection string here"); //... but maybe you should be more specific. what exactly do you want to do with the data? bind to a grid?... Also, what version of Asp.Net

      acodeisacodeisacode

      V 1 Reply Last reply
      0
      • B bayo

        Hello Adil, you can use OleDbConnection, for e.g using System.Data.OleDb; //... //... //... OledbConnection conn = new OleDbConnection("your connection string here"); //... but maybe you should be more specific. what exactly do you want to do with the data? bind to a grid?... Also, what version of Asp.Net

        acodeisacodeisacode

        V Offline
        V Offline
        v450305
        wrote on last edited by
        #3

        hi dear I was trying to use following code ..but it is not working properly. Imports System.Data.OleDb Public Class Form1 Inherits System.Windows.Forms.Form Dim cn As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader Private Sub Form1_Load(ByVal sender As System.Object, ByVal e as _ System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_ System.EventArgs) Handles Button1.Click Try cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_ Data Source=C:\emp.mdb;") 'provider to be used when working with access database cn.Open() cmd = New OleDbCommand("select * from table1", cn) dr = cmd.ExecuteReader While dr.Read() TextBox1.Text = dr(0) TextBox2.Text = dr(1) TextBox3.Text = dr(2) ' loading data into TextBoxes by column index End While Catch End Try dr.Close() cn.Close() End Sub End Class regards adil

        G B 2 Replies Last reply
        0
        • V v450305

          hi dear I was trying to use following code ..but it is not working properly. Imports System.Data.OleDb Public Class Form1 Inherits System.Windows.Forms.Form Dim cn As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader Private Sub Form1_Load(ByVal sender As System.Object, ByVal e as _ System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_ System.EventArgs) Handles Button1.Click Try cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_ Data Source=C:\emp.mdb;") 'provider to be used when working with access database cn.Open() cmd = New OleDbCommand("select * from table1", cn) dr = cmd.ExecuteReader While dr.Read() TextBox1.Text = dr(0) TextBox2.Text = dr(1) TextBox3.Text = dr(2) ' loading data into TextBoxes by column index End While Catch End Try dr.Close() cn.Close() End Sub End Class regards adil

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Standard question #1: What do you mean by "not working"? Standard question #2: What error message do you get?

          --- single minded; short sighted; long gone;

          1 Reply Last reply
          0
          • V v450305

            hi dear I was trying to use following code ..but it is not working properly. Imports System.Data.OleDb Public Class Form1 Inherits System.Windows.Forms.Form Dim cn As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader Private Sub Form1_Load(ByVal sender As System.Object, ByVal e as _ System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_ System.EventArgs) Handles Button1.Click Try cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;_ Data Source=C:\emp.mdb;") 'provider to be used when working with access database cn.Open() cmd = New OleDbCommand("select * from table1", cn) dr = cmd.ExecuteReader While dr.Read() TextBox1.Text = dr(0) TextBox2.Text = dr(1) TextBox3.Text = dr(2) ' loading data into TextBoxes by column index End While Catch End Try dr.Close() cn.Close() End Sub End Class regards adil

            B Offline
            B Offline
            bayo
            wrote on last edited by
            #5

            Hi Adil, You said something about ASP.Net but it looks like it is a windows form you are dealing with. Anyhow, it doesn't matter. What you can do is put a breakpoint in your code for the Button click event Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As_ System.EventArgs) Handles Button1.Click then step though the code and find out where it breaks. This would give us info enough to help you. Meanwhile, i expect that the database has a table, Table1 with at least 3 fields that are all of Text type (?). (gain maybe it would help for you to go with: TextBox1.Text = dr(0).ToString().....etc

            acodeisacodeisacode

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups