dc

dc

  • NA
  • 663
  • 0

web form obtain data

Aug 23 2016 1:09 PM

For a web form vb.net 2010 application, I want to make a call to the sql server 2012 database from the code listed below. This code is executed when the user clicks on a link in a gridview control.  I want to make a call to the database to make certain there is not more than one student record that would be in the database due to a user error. This error can be caused by the user working with the vendor software than I have no control over.

My plan is to display an error message to the user and place a 'return' in the code listed below.

Thus can you show me code and/or point me to a url that will show me how I can connect to the database from the code listed below:
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="default.aspx.vb" Inherits="attendanceletters_default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MPHead" Runat="Server">
    <script src="../scripts/jquery-1.3.2.js" type="text/javascript"></script>
    <script src="../scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
   <script src="../scripts/site.js" type="text/javascript"></script>
    <script src="../scripts/json2.js" type="text/javascript"></script>
       
    <script type="text/javascript">
        var _schoolyear;
        var _schoolnum;
         var _studentlink;
        var _language;
         
        function GetSt(schoolyear, schoolnum,  studentlink, language) {
     

            if (language == '') {
                language = 'EN'
            }
            else if (language == 'SPA') {
                language = 'ES'
            }

            _schoolyear = schoolyear;
            _schoolnum = schoolnum;
            _studentlink = studentlink;
            _language = language;
          
            $('#<%= txtStuLink.ClientID%>').val(studentlink);
            $('#<%= txtLanguage.ClientID%>').val(language);
           
            var strData = "schoolyear: " + JSON.stringify(schoolyear) + ", "
                + "schoolnum: " + JSON.stringify(schoolnum) + ", "          
                + "studentlink: " + JSON.stringify(studentlink) + ", "
                + "language: " + JSON.stringify(language) + ", "
                + "semester: " + JSON.stringify(semester) + "";

         
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: document.location.pathname + "/GetStudentLetter",
                data: "{ " + strData + " }",
                dataType: "json",
                success: function(data) {
                    LoadEditor(JSON.parse(data.d), milestone);
                },
                error: AjaxFailed
            });

        }


       
          
    </script>

 


Answers (1)