Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Display a database information

paulvbpaulvb Posts: 42Member
Using 2002 visual studio software, my dataset is called "con1" i need to display in datagrid1. can anyone help???

Comments

  • kainsworthkainsworth Posts: 200Member
    : Using 2002 visual studio software, my dataset is called "con1" i need to display in datagrid1. can anyone help???
    :

    ==============

    Strictly speaking, the answer is:
    [code]
    Datagrid1.DataSource = con1
    [/code]

    but you probably won't be 100% happy with the result. The data is there in the grid but it requires some mouseclicks to reveal it all, as you will see if you try it.

    A better version would be
    [code]
    Datagrid1.DataSource = con1.Tables(0)
    [/code]

    assuming that you want the data from the first table only to populate the datagrid.

    In passing, I suggest you might want to change the name of your dataset to something else. It's generally good practice to use names that give some indication of what a variable or an object is meant to do. Calling a DataSet "con" might cause you confusion later, because once you've long since forgotten how you did it all, you may go back and read your code and think that con1 is the DataConnection you used, not the DataSet. Something like DS1 would be a much, much better name for a DataSet.

    Hope this helps

    Ged


  • paulvbpaulvb Posts: 42Member
    [b][red]This message was edited by paulvb at 2004-11-1 9:44:56[/red][/b][hr]
    : : Using 2002 visual studio software, my dataset is called "con1" i need to display in datagrid1. can anyone help???
    : :
    :
    : ==============
    :
    : Strictly speaking, the answer is:
    : [code]
    : Datagrid1.DataSource = con1
    : [/code]
    :
    : but you probably won't be 100% happy with the result. The data is there in the grid but it requires some mouseclicks to reveal it all, as you will see if you try it.
    :
    : A better version would be
    : [code]
    : Datagrid1.DataSource = con1.Tables(0)
    : [/code]
    :
    : assuming that you want the data from the first table only to populate the datagrid.
    :
    : In passing, I suggest you might want to change the name of your dataset to something else. It's generally good practice to use names that give some indication of what a variable or an object is meant to do. Calling a DataSet "con" might cause you confusion later, because once you've long since forgotten how you did it all, you may go back and read your code and think that con1 is the DataConnection you used, not the DataSet. Something like DS1 would be a much, much better name for a DataSet.
    :
    : Hope this helps
    :
    : Ged
    :
    : hi this display the titles of the database, but does not display the variable data contained under the titles?

    paulvb

    :



  • kainsworthkainsworth Posts: 200Member
    If you are using a DataAdapter and the Fill method, check that it isn't using FillSchema instead of Fill. This would cause the problem you describe.

    You don't say in your post how you have populated (ie. read the data into) your DataSet. I begin to suspect that your con1, which you refer to as a dataset might really be a Connection object.

    If you post up the code you are using to connect to the database, extract data from the database, and fill the dataset, it would make it easier to find out where your problem arises. :-)


    Ged
    ========================================================================


    : [b][red]This message was edited by paulvb at 2004-11-1 9:44:56[/red][/b][hr]
    : : : Using 2002 visual studio software, my dataset is called "con1" i need to display in datagrid1. can anyone help???
    : : :
    : :
    : : ==============
    : :
    : : Strictly speaking, the answer is:
    : : [code]
    : : Datagrid1.DataSource = con1
    : : [/code]
    : :
    : : but you probably won't be 100% happy with the result. The data is there in the grid but it requires some mouseclicks to reveal it all, as you will see if you try it.
    : :
    : : A better version would be
    : : [code]
    : : Datagrid1.DataSource = con1.Tables(0)
    : : [/code]
    : :
    : : assuming that you want the data from the first table only to populate the datagrid.
    : :
    : : In passing, I suggest you might want to change the name of your dataset to something else. It's generally good practice to use names that give some indication of what a variable or an object is meant to do. Calling a DataSet "con" might cause you confusion later, because once you've long since forgotten how you did it all, you may go back and read your code and think that con1 is the DataConnection you used, not the DataSet. Something like DS1 would be a much, much better name for a DataSet.
    : :
    : : Hope this helps
    : :
    : : Ged
    : :
    : : hi this display the titles of the database, but does not display the variable data contained under the titles?
    :
    : paulvb
    :
    : :
    :
    :
    :
    :

  • paulvbpaulvb Posts: 42Member
    : If you are using a DataAdapter and the Fill method, check that it isn't using FillSchema instead of Fill. This would cause the problem you describe.
    :
    : You don't say in your post how you have populated (ie. read the data into) your DataSet. I begin to suspect that your con1, which you refer to as a dataset might really be a Connection object.
    :
    : If you post up the code you are using to connect to the database, extract data from the database, and fill the dataset, it would make it easier to find out where your problem arises. :-)
    :
    :
    : Ged
    :
    Hi Ged
    How do you use the fill function?

    paulvb

    :
    :
    : : [b][red]This message was edited by paulvb at 2004-11-1 9:44:56[/red][/b][hr]
    : : : : Using 2002 visual studio software, my dataset is called "con1" i need to display in datagrid1. can anyone help???
    : : : :
    : : :
    : : : ==============
    : : :
    : : : Strictly speaking, the answer is:
    : : : [code]
    : : : Datagrid1.DataSource = con1
    : : : [/code]
    : : :
    : : : but you probably won't be 100% happy with the result. The data is there in the grid but it requires some mouseclicks to reveal it all, as you will see if you try it.
    : : :
    : : : A better version would be
    : : : [code]
    : : : Datagrid1.DataSource = con1.Tables(0)
    : : : [/code]
    : : :
    : : : assuming that you want the data from the first table only to populate the datagrid.
    : : :
    : : : In passing, I suggest you might want to change the name of your dataset to something else. It's generally good practice to use names that give some indication of what a variable or an object is meant to do. Calling a DataSet "con" might cause you confusion later, because once you've long since forgotten how you did it all, you may go back and read your code and think that con1 is the DataConnection you used, not the DataSet. Something like DS1 would be a much, much better name for a DataSet.
    : : :
    : : : Hope this helps
    : : :
    : : : Ged
    : : :
    : : : hi this display the titles of the database, but does not display the variable data contained under the titles?
    : :
    : : paulvb
    : :
    : : :
    : :
    : :
    : :
    : :
    :
    :

Sign In or Register to comment.