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. dataset to formview

dataset to formview

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasehelpquestion
3 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.
  • A Offline
    A Offline
    Arif Liminto
    wrote on last edited by
    #1

    Hi, I am still a newbie in ASP.net, sorry if I am asking stupid message. I am trying to develop some website using asp.net 2.0 and I currently have some difficulity to use one of the ToolBox called FormView for displaying the data from database I want to transfer from microsoft access to FormView here is the code

    OleDbConnection myConnection = new OleDbConnection(myConnectionString);
    myConnection.Open();

    OleDbCommand myCommand = new OleDbCommand();
    myCommand.Conn = myConnection;
    myCommand.CommandText = "SELECT * FROM [USER] WHERE UserName = @UserName";
    myCommand.Parameters.AddWithValue("@UserName",sUserName);

    OleDbDataAdapter myAdapter = new OleDbDataAdapter(myCommand);

    myDataAdapter.Fill(myDataSet);

    FORM_View_Users.DataSource = myDataSet;
    FORM_View_Users.DataBind();

    myConnection.Close();

    I think I did with the correct way because when I tried to run the website, I did not get any exception error, However, I couldn't see the formview, it just blank . Is there any attribute that I need to fill in so I can see the data in the Form_View ? thanks

    C 1 Reply Last reply
    0
    • A Arif Liminto

      Hi, I am still a newbie in ASP.net, sorry if I am asking stupid message. I am trying to develop some website using asp.net 2.0 and I currently have some difficulity to use one of the ToolBox called FormView for displaying the data from database I want to transfer from microsoft access to FormView here is the code

      OleDbConnection myConnection = new OleDbConnection(myConnectionString);
      myConnection.Open();

      OleDbCommand myCommand = new OleDbCommand();
      myCommand.Conn = myConnection;
      myCommand.CommandText = "SELECT * FROM [USER] WHERE UserName = @UserName";
      myCommand.Parameters.AddWithValue("@UserName",sUserName);

      OleDbDataAdapter myAdapter = new OleDbDataAdapter(myCommand);

      myDataAdapter.Fill(myDataSet);

      FORM_View_Users.DataSource = myDataSet;
      FORM_View_Users.DataBind();

      myConnection.Close();

      I think I did with the correct way because when I tried to run the website, I did not get any exception error, However, I couldn't see the formview, it just blank . Is there any attribute that I need to fill in so I can see the data in the Form_View ? thanks

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Have you stepped through the code to make sure that there is data in the dataset ?

      Christian Graus Driven to the arms of OSX by Vista.

      A 1 Reply Last reply
      0
      • C Christian Graus

        Have you stepped through the code to make sure that there is data in the dataset ?

        Christian Graus Driven to the arms of OSX by Vista.

        A Offline
        A Offline
        Arif Liminto
        wrote on last edited by
        #3

        yeah I've stepped through the code i also try to add some debug code

        bool bResult = false;

        if(myDataAdapter.Fill(myDataSet) > 0)
        {
        bResult = true;
        }

        and I monitor the value of bResult, the result is true. if I use GridView,it works perfectly, so I dont think there is a mistake in transferring from database to dataset, I suspect the problem when transfering from DataSet to FormView, which i use the same mechanism when i use GridView set the data source -> FormView.DataSource = DataSet; bind the data -> FormView.DataBind(); is there anything that I need to add more? Thanks so much

        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