jQuery UI Widgets Forums Grid ASP and MSsql database

Tagged: , ,

This topic contains 4 replies, has 2 voices, and was last updated by  Peter Stoev 12 years, 7 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • ASP and MSsql database #3619

    Stephen
    Member

    Hi,

    how to connect Grid to a asp classic to MSsql ?

    Usually I use this type of connection for asp and sql.

    Thank you for your help !

    ASP and MSsql database #3620

    Stephen
    Member

    sql=”SELECT * FROM mytable;”
    Set objConn= Server.CreateObject(“ADODB.Connection”)
    Set objRec= Server.CreateObject(“ADODB.Recordset”)
    objConn.Open strConnect
    objRec.Open sql, objConn,0,1,1
    While Not objRec.EOF

    objRec.movenext
    wend
    objRec.Close
    objConn.close
    Set objRec=nothing
    Set objConn=nothing

    ASP and MSsql database #3639

    Peter Stoev
    Keymaster

    Hi Stephen,

    We created this blog post for you: using-jquery-grid-with-asp-net-and-sql-server. The post illustrates how to use the jqxGrid in ASP .NET Web Application and get the data from SQL Database. The sample code uses the Northwind.mdf database and the Grid displays the Customers table.

    Hope this helps you.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    ASP and MSsql database #3650

    Stephen
    Member

    Thank’s for the fast post.

    I use your code and it work perfecly .. how to use with ASP Classic (asp 3.0) ?

    ASP and MSsql database #3672

    Peter Stoev
    Keymaster

    Hi Stephen,

    With classic ASP, I think that you can use the same approach as with ASP .NET for the client-side code. The data is extracted with the jQuery’s ajax function and the Grid is populated with the jqxDataAdapter. Another possible approach is to get the data from SQL Database and then store it into a JavaScript array and then load the Grid from the array.

        <link href="Styles/jqx.base.css" rel="stylesheet" type="text/css" />
    <link href="Styles/jqx.classic.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="Scripts/jqxcore.js" type="text/javascript"></script>
    <script src="Scripts/jqxbuttons.js" type="text/javascript"></script>
    <script src="Scripts/jqxdata.js" type="text/javascript"></script>
    <script src="Scripts/jqxgrid.js" type="text/javascript"></script>
    <script src="Scripts/jqxgrid.selection.js" type="text/javascript"></script>
    <script src="Scripts/jqxmenu.js" type="text/javascript"></script>
    <script src="Scripts/jqxscrollbar.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    //Getting the source data with ajax GET request
    source = {
    datatype: "xml",
    datafields: [
    { name: 'CompanyName' },
    { name: 'ContactName' },
    { name: 'ContactTitle' },
    { name: 'City' },
    { name: 'Country' },
    { name: 'Address' }
    ],
    async: false,
    record: 'Table',
    url: 'Default.aspx/GetCustomers',
    };
    var dataAdapter = new $.jqx.dataAdapter(source,
    { contentType: 'application/json; charset=utf-8'}
    );
    $("#jqxgrid").jqxGrid({
    source: dataAdapter,
    theme: 'classic',
    columns: [
    { text: 'Company Name', dataField: 'CompanyName', width: 250 },
    { text: 'Contact Name', dataField: 'ContactName', width: 150 },
    { text: 'Contact Title', dataField: 'ContactTitle', width: 180 },
    { text: 'Address', dataField: 'Address', width: 180},
    { text: 'City', dataField: 'City', width: 80 },
    { text: 'Country', dataField: 'Country', width: 100}
    ]
    });
    });
    </script>

    I also suggest you to take a look at this blog post here: http://www.mikesdotnetting.com/Article/98/Ajax-with-Classic-ASP-using-jQuery. The post demonstrates how to retrieve data in JSON format from SQL Database using jQuery and Ajax. When you get the data in JSON format, you can populate the Grid by using the same approach as in this demo: bindingtojson.htm.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.