Я использую Visual Studio 2017 с C #, у меня есть таблица HTML, и я хочу импортировать данные из SQL Server.
Код представляет собой таблицу HTML, в которую пользователь будет вводить только цифрыи в конце суммируется, затем при нажатии кнопки сохранения данные должны быть сохранены в таблице SQL Server.
<table id="tablaConsultaSocial" class="table table-borderless table-responsive table-hover " >
<thead class=" p-3 mb-2 bg-primary text-white table-bordered table-hover " .bg-primary>
<tr >
<th class="text-center" scope="col" colspan="7" >TIPO CONSULTA</th>
<td class="text-center " rowspan="2"><p class="verticalText">CÓDIDO</p></td>
<th scope="col" class="text-center " colspan="4">CONSULTA SOCIAL</th>
</tr>
<tr >
<th scope="col" class="text-center" colspan="7" >ÁREA ATENCIÓN</th>
<th scope="col" class="text-center" colspan="4" >CONSULTA EXTERNA</th>
</tr>
<tr>
<th scope="col" class="text-center" colspan="7" >DIAGNÓSTICO</th>
<th></th>
<th scope="col" class="text-center">Total</th>
<th scope="col" class="text-center">Individual</th>
<th scope="col" class="text-center">Familiar</th>
<th scope="col" class="text-center">Grupal</th>
</tr>
<tr>
<th class="text-center" colspan="7" scope="col">CÓDIGO</th>
<th ></th>
<th scope="col" class="text-center">001</th>
<th scope="col" class="text-center">002</th>
<th scope="col" class="text-center">003</th>
<th scope="col" class="text-center">004</th>
</thead>
<tfoot>
<tr class="bg-info text-center">
<td colspan="5" >Total</td>
<td class="totalCol" style="text-align: center; vertical-align: middle;"> </td>
<td class="totalCol" style="text-align: center; vertical-align: middle;"> </td>
<td class="totalCol" style="text-align: center; vertical-align: middle;"> </td>
<td class="totalCol" style="text-align: center; vertical-align: middle;"> </td>
<td class="totalCol" style="text-align: center; vertical-align: middle;"> </td>
<td class="totalCol" style="text-align: center; vertical-align: middle;"> </td>
<td class="totalCol" style="text-align: center; vertical-align: middle;"> </td>
</tr>
</tfoot>
<tr>
<td colspan="13">
<div >
<table >
<tbody>
<tr class="table-secondary">
<td colspan="6" >Negligencia o abandono</td>
<td></td>
<td style="text-align: center; vertical-align: middle;">T74.0</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="12" maxlength="5"/>
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="23" maxlength="5"/>
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="18" maxlength="5"/>
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="12" maxlength="5"/>
</td>
</tr>
<tr class="table-secondary">
<td colspan="6" >Abuso Físico</td>
<td></td>
<td style="text-align: center; vertical-align: middle;">T74.1</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="12" maxlength="5"/>
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="23" maxlength="5"/>
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="18" maxlength="5"/>
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="12" maxlength="5"/>
</td>
</tr>
<tr class="table-secondary">
<td colspan="6" >Abuso sexual</td>
<td></td>
<td style="text-align: center; vertical-align: middle;">T74.2</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="12" maxlength="5"/>
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="23" maxlength="5"/>
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="18" maxlength="5"/>
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="12" maxlength="5"/>
</td>
</tr>
<tr class="table-secondary">
<td colspan="6" >Abuso psicológico</td>
<td></td>
<td style="text-align: center; vertical-align: middle;">T74.3</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="12" maxlength="5"/>
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="23" maxlength="5"/>
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="18" maxlength="5"/>
</td>
<td style="text-align: center; vertical-align: middle;">
<input type="text" class="saisie table-secondary numberinput text-center " onkeyup="sumar2(this.id); return ValNumero(this); return limitar(event, this.value, 4);" onKeyDown="return limitar(event,this.value,4)" onKeyPress="return soloNumeros(event); return limitar(event, this.value, 4);" onBlur="verifica(this.id);" onfocus="control_clear(this)" value="0" size="12" maxlength="5"/>
</td>
</tr>
</table>
<script >
// event to fire on Save button click //
$(document).on('click', '#btnSave', function () {
var data = HTMLtbl.getData($('#tablaConsultaSocial'));
var parameters = {};
parameters.array = data;
var request = $.ajax({
async: true,
cache: false,
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Cuadro_42.aspx/SaveData",
data: JSON.stringify(parameters)
});
request.done(function (msg) {
alert("Row saved " + msg.d);
});
request.fail(function (jqXHR, textStatus) {
alert("Request failed: " + textStatus);
});
});
//function to convert HTML table to jagged array//
var HTMLtbl =
{
getData: function (table) {
var data = [];
table.find('tr').not(':first').each(function (rowIndex, r) {
var cols = [];
$(this).find('td').each(function (colIndex, c) {
if ($(this).children(':text,:hidden,textarea,select').length > 0) //text//hidden//textarea//select
cols.push($(this).children('input,textarea,select').val().trim());
// if dropdown text is needed then uncomment it and remove SELECT from above IF condition//
// else if ($(this).children('select').length > 0)
// cols.push($(this).find('option:selected').text());
else if ($(this).children(':checkbox').length > 0) // checkbox
cols.push($(this).children(':checkbox').is(':checked') ? 1 : 0); //or true false
else
cols.push($(this).text().trim()); // get td Value
});
data.push(cols);
});
return data;
}
}
</script>
Это приводит к следующей ошибке:
Строка сохранена неопределенной
Мне нужно иметь возможность зарегистрировать данные в таблице HTML в SQL Server.