Thursday, July 12, 2018

cshtml database connection c# mvc

@using WebMatrix.Data;

@{
    /**/


    ViewBag.Title = "About";
    var db = Database.Open("vislidbConnectionString");
    var selectQueryString = "SELECT * FROM [vislidb].[dbo].[tbl_OrderUserDetails]";


}
<h2>@ViewBag.Title.</h2>
<h3>@ViewBag.Message</h3>


<p>Use this area to provide additional information.</p>
<p>
    this is test1

</p>
<p>
    this is test2

</p>

<p>

    <table>
        <thead>
            <tr>
                <th>Id</th>
                <th>Product</th>
                <th>Description</th>
                <th>Price</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var row in db.Query(selectQueryString))
            {
                <tr>
                    <td>@row.UDUSRID</td>
                    <td>@row.UDPASSWD</td>
                    <td>@row.UDFNAM</td>
                    <td>@row.UDLNAM</td>
                </tr>
            }
        </tbody>
    </table>

</p>

No comments: