Hi trisetia302,
Refer modified code.
HTML
<div class="col-lg-3 col-6">
<!-- small box -->
<div class="small-box bg-warning">
<div class="inner">
<h3><b>
<asp:Label ID="Label_Jumlah_Simpanan" runat="server" Text=""></asp:Label></b></h3>
<p>Jumlah Simpanan</p>
</div>
<div class="icon">
<i class="ion ion-person-add"></i>
</div>
<a href="<%=Page.ResolveClientUrl("~/View/Simpanan.aspx")%>" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
</div>
</div>
Namespaces
C#
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
VB.Net
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Code
C#
string koneksi = ConfigurationManager.ConnectionStrings["db_koperasiConnectionString"].ConnectionString.ToString();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadData();
}
}
private void LoadData()
{
using (SqlConnection con = new SqlConnection(koneksi))
{
using (SqlCommand cmd = new SqlCommand())
{
try
{
con.Open();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select SUM(jumlah_simpanan) From tbl_simpanan";
Label_Jumlah_Simpanan.Text = Convert.ToString(string.Format("{0:Rp 0,00.00}", Convert.ToString(cmd.ExecuteScalar())));
con.Close();
}
catch (Exception ex)
{
throw ex;
}
}
}
}
VB.Net
Private koneksi As String = ConfigurationManager.ConnectionStrings("db_koperasiConnectionString").ConnectionString.ToString()
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
LoadData()
End If
End Sub
Private Sub LoadData()
Using con As SqlConnection = New SqlConnection(koneksi)
Using cmd As SqlCommand = New SqlCommand()
Try
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.Text
cmd.CommandText = "Select SUM(jumlah_simpanan) From tbl_simpanan"
Label_Jumlah_Simpanan.Text = Convert.ToString(String.Format("{0:Rp 0,00.00}", Convert.ToString(cmd.ExecuteScalar())))
con.Close()
Catch ex As Exception
Throw ex
End Try
End Using
End Using
End Sub