GridView with a View

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mikaël PLOUHINEC

    GridView with a View

    Hello,

    I work with SQL Server 2005 and a dataset in my VS.NET project. I would
    like to use a GridView. Is that possible to use a grid View and
    configure his datasource with a View (in SQL Server)?

    How can I do that?

    Thanks a lot.

    Mike
  • JPS

    #2
    Re: GridView with a View

    Here is a code sample of how to create a dataset and populate the
    gridview

    DataSet myDataSet = new DataSet("ds1");
    string sql = "Select * from Customer";
    SqlConnection myConnection = new SqlConnection(@ "Data
    Source=MYSqlDB; Integrated Security=SSPI;" Initial Catalog=Northwi nd");
    SqlCommand cmd1 = new SqlCommand(sql) ;
    cmd1.CommandTyp e = CommandType.Tex t;
    myConnection.Op en();
    cmd1.Connection = myConnection;
    SqlDataAdapter sqlDAdapt = new SqlDataAdapter( );
    sqlDAdapt.Selec tCommand=cmd1;
    sqlDAdapt.Fill( myDataSet,"Acco unt");
    myGridView.Data Source = myDataSet.Table s[0];

    Let me know if you have any questions
    +

    On Nov 7, 6:19 am, Mikaël PLOUHINEC <m...@cerealog. frwrote:
    Hello,
    >
    I work with SQL Server 2005 and a dataset in my VS.NET project. I would
    like to use a GridView. Is that possible to use a grid View and
    configure his datasource with a View (in SQL Server)?

    How can I do that?

    Thanks a lot.

    Mike

    Comment

    Working...