Wednesday, February 22, 2012

Read & Display SQL data into Label

Code:

Dim conn As New SqlConnection
(ConfigurationManager.ConnectionStrings("SqlServerExecSP").ToString())
conn.Open()
Dim sql As String = "Select Name from People where Id = 1"
Dim cmd As SqlCommand = New SqlCommand(sql, conn)
Dim rd As SqlDataReader = cmd.ExecuteReader()

While rd.Read()
label1.Text = rd("Name")
End While


Change the connection string and table name in the above code.

Happy Programming!!

Checkbox-- Select at least one box using jQuery

Code:
<script>
$(document).ready(function () {
$('.error').hide();
$('.submit').click(function (event) {
var count = $('input:checked').length;
if (count == 0) {
alert("select at least one");
return false;
}
else

{
return true;
}
});
});
</script>

<input id="app" class="box" value="5" type="checkbox" name="apple">Apple$5

<input id="ora" class="box" value="2" type="checkbox" name="orange">Orange $2

<input id="mel" class="box" value="1" type="checkbox" name="melon">Melon$1

<input id="gra" class="box" value="3" type="checkbox" name="grape">Grapes $3

<input class="submit" value="Submit" type="submit">


more:
http://code.google.com/p/m-jq-projects/wiki/enableControlOnCheck_jQuery