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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to bring the Ms-Access DB record to a DropdownList?

How to bring the Ms-Access DB record to a DropdownList?

Scheduled Pinned Locked Moved ASP.NET
helpdatabasetutorialquestion
5 Posts 2 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.
  • P Offline
    P Offline
    Praveen 123
    wrote on last edited by
    #1

    the following code is for connecting a DropdownList with a Ms-access record but its not working.....Pleas help me Dim DBConnection As System.Data.OleDb.OleDbConnection Dim DBCommand As System.Data.OleDb.OleDbCommand Dim DBReader As System.Data.OleDb.OleDbDataReader Dim SQLString As String Dim DataSet1 As System.Data.DataSet If Not Page.IsPostBack Then DBConnection = New System.Data.OleDb.OleDbConnection( _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\Documents and Settings\All Users\Documents\Attendance\BTA_ DB_Design\BTAS.mdb") DBConnection.Open() DBCommand = New OleDb.OleDbCommand("SELECT Employee_ID FROM Attendance_Details", DBConnection) OleDbDataAdapter1.SelectCommand = DBCommand OleDbDataAdapter1.Fill(DataSet1, "Attendance_Details") DropDownList1.DataSource = DataSet1.Tables("Attendance_Details") DropDownList1.DataValueField = "Employee_ID" DropDownList1.DataBind() DBReader.Close() DBConnection.Close() Error:-Value cannot be null. Parameter name: dataSet

    Praveen.K System Engineer Graviton Technologies Pvt.Ltd

    K P 2 Replies Last reply
    0
    • P Praveen 123

      the following code is for connecting a DropdownList with a Ms-access record but its not working.....Pleas help me Dim DBConnection As System.Data.OleDb.OleDbConnection Dim DBCommand As System.Data.OleDb.OleDbCommand Dim DBReader As System.Data.OleDb.OleDbDataReader Dim SQLString As String Dim DataSet1 As System.Data.DataSet If Not Page.IsPostBack Then DBConnection = New System.Data.OleDb.OleDbConnection( _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\Documents and Settings\All Users\Documents\Attendance\BTA_ DB_Design\BTAS.mdb") DBConnection.Open() DBCommand = New OleDb.OleDbCommand("SELECT Employee_ID FROM Attendance_Details", DBConnection) OleDbDataAdapter1.SelectCommand = DBCommand OleDbDataAdapter1.Fill(DataSet1, "Attendance_Details") DropDownList1.DataSource = DataSet1.Tables("Attendance_Details") DropDownList1.DataValueField = "Employee_ID" DropDownList1.DataBind() DBReader.Close() DBConnection.Close() Error:-Value cannot be null. Parameter name: dataSet

      Praveen.K System Engineer Graviton Technologies Pvt.Ltd

      K Offline
      K Offline
      krishnakumark
      wrote on last edited by
      #2

      Initialize data set before filling it ... like .. DataSet1 = New DataSet OleDbDataAdapter1.Fill(DataSet1, "Attendance_Details") also remove DBReader.Close() .. because you have not used it at alll...

      Kk

      1 Reply Last reply
      0
      • P Praveen 123

        the following code is for connecting a DropdownList with a Ms-access record but its not working.....Pleas help me Dim DBConnection As System.Data.OleDb.OleDbConnection Dim DBCommand As System.Data.OleDb.OleDbCommand Dim DBReader As System.Data.OleDb.OleDbDataReader Dim SQLString As String Dim DataSet1 As System.Data.DataSet If Not Page.IsPostBack Then DBConnection = New System.Data.OleDb.OleDbConnection( _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\Documents and Settings\All Users\Documents\Attendance\BTA_ DB_Design\BTAS.mdb") DBConnection.Open() DBCommand = New OleDb.OleDbCommand("SELECT Employee_ID FROM Attendance_Details", DBConnection) OleDbDataAdapter1.SelectCommand = DBCommand OleDbDataAdapter1.Fill(DataSet1, "Attendance_Details") DropDownList1.DataSource = DataSet1.Tables("Attendance_Details") DropDownList1.DataValueField = "Employee_ID" DropDownList1.DataBind() DBReader.Close() DBConnection.Close() Error:-Value cannot be null. Parameter name: dataSet

        Praveen.K System Engineer Graviton Technologies Pvt.Ltd

        P Offline
        P Offline
        Praveen 123
        wrote on last edited by
        #3

        sir after the specified modification the following line of error is appearing. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source of error::: ----------------------------------- DBConnection.Open() Line 39: DBCommand = New OleDb.OleDbCommand("SELECT Employee_ID FROM Attendance_Details", DBConnection) Error line:-Line 40: OleDbDataAdapter1.SelectCommand = DBCommand Line 41: DataSet1 = New DataSet Line 42: OleDbDataAdapter1.Fill(DataSet1, "Attendance_Details") -- modified at 23:39 Wednesday 31st January, 2007

        Praveen.K System Engineer Graviton Technologies Pvt.Ltd

        K 1 Reply Last reply
        0
        • P Praveen 123

          sir after the specified modification the following line of error is appearing. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source of error::: ----------------------------------- DBConnection.Open() Line 39: DBCommand = New OleDb.OleDbCommand("SELECT Employee_ID FROM Attendance_Details", DBConnection) Error line:-Line 40: OleDbDataAdapter1.SelectCommand = DBCommand Line 41: DataSet1 = New DataSet Line 42: OleDbDataAdapter1.Fill(DataSet1, "Attendance_Details") -- modified at 23:39 Wednesday 31st January, 2007

          Praveen.K System Engineer Graviton Technologies Pvt.Ltd

          K Offline
          K Offline
          krishnakumark
          wrote on last edited by
          #4

          Hi it should look similer to this.. i tried here.. its working fine...did you remove the statement DBReader.Close() ????? Dim DBConnection As System.Data.OleDb.OleDbConnection Dim DBCommand As System.Data.OleDb.OleDbCommand Dim DBReader As System.Data.OleDb.OleDbDataReader Dim SQLString As String Dim DataSet1 As System.Data.DataSet If Not Page.IsPostBack Then DBConnection = New System.Data.OleDb.OleDbConnection( _ "put your connection string here") DBConnection.Open() DBCommand = New OleDb.OleDbCommand("select email from users", DBConnection) OleDbDataAdapter1.SelectCommand = DBCommand DataSet1 = New DataSet OleDbDataAdapter1.Fill(DataSet1, "Attendance_Details") DropDownList1.DataSource = DataSet1.Tables("Attendance_Details") DropDownList1.DataValueField = "email" DropDownList1.DataBind() DBConnection.Close() End If

          Kk

          P 1 Reply Last reply
          0
          • K krishnakumark

            Hi it should look similer to this.. i tried here.. its working fine...did you remove the statement DBReader.Close() ????? Dim DBConnection As System.Data.OleDb.OleDbConnection Dim DBCommand As System.Data.OleDb.OleDbCommand Dim DBReader As System.Data.OleDb.OleDbDataReader Dim SQLString As String Dim DataSet1 As System.Data.DataSet If Not Page.IsPostBack Then DBConnection = New System.Data.OleDb.OleDbConnection( _ "put your connection string here") DBConnection.Open() DBCommand = New OleDb.OleDbCommand("select email from users", DBConnection) OleDbDataAdapter1.SelectCommand = DBCommand DataSet1 = New DataSet OleDbDataAdapter1.Fill(DataSet1, "Attendance_Details") DropDownList1.DataSource = DataSet1.Tables("Attendance_Details") DropDownList1.DataValueField = "email" DropDownList1.DataBind() DBConnection.Close() End If

            Kk

            P Offline
            P Offline
            Praveen 123
            wrote on last edited by
            #5

            yes, Its working sir.the problem was with my database...The problem was when i am working with a database in a user permission account i cant access the DB.When i changed the location of the DB to some other system directory, it works.Any way thanks for u'r asistance. Regards

            Praveen.K System Engineer Graviton Technologies Pvt.Ltd

            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