从数据表中获取价值(getting value from datatable)
谁能告诉我如何从数据表中获取价值? 我在数据表中只有一行和一列,我需要获取列的值来进行计算。
这是我的剧本
<SCRIPT Language="VB" Runat="server"> Sub Page_Load(Source as object, e as EventArgs) handles me.load Dim connectionstring As String = "DRIVER={MySQL ODBC 5.2 Unicode Driver}; SERVER=localhost; DATABASE=mydb; UID=andrew; PASSWORD=kh12345; OPTION=3" Dim connectme As OdbcConnection = New OdbcConnection(connectionstring) Dim sqlquery As String = "SELECT f_name, f_price from tbl_picture WHERE f_ID = 1" Dim ODBCdataadapter As OdbcDataAdapter = New OdbcDataAdapter(sqlquery, connectme) Dim ODBCdataset As DataSet = New DataSet() ODBCdataadapter.Fill(ODBCdataset) DataTable.DataSource = ODBCdataset DataTable1.DataSource = ODBCdataset Datatable.DataBind() Datatable1.DataBind() End Sub </SCRIPT > <ASP:Datagrid ID="Datatable1" Runat="server" AutoGenerateColumns="False"BorderStyle="None" GridLines="None"> <Columns> <asp:BoundColumn DataField="f_price" ReadOnly="True"/> </columns> </asp:DataGrid>
这是计算部分
Private Sub CalculatePayment() Dim c_loan_amount, c_Payment Dim amount As String = Datatable1.Select("f_price") c_loan_amount = amount - (amount * Down.Text * 0.01) c_Payment = ((c_loan_amount * (Interest.Text * 0.01) * Year.Text) + c_loan_amount) / (Year.Text * 12) Payment.Text = "RM " & Format(c_Payment, "#,##0.00") End Sub
它应该是昏暗的数量作为字符串部分吗? 我有点新,谢谢你。
Can anyone please tell me how to get value from datatable? I've only got one row and one column in the datatable and I need to get the value of the column to do calculations.
here's my script
<SCRIPT Language="VB" Runat="server"> Sub Page_Load(Source as object, e as EventArgs) handles me.load Dim connectionstring As String = "DRIVER={MySQL ODBC 5.2 Unicode Driver}; SERVER=localhost; DATABASE=mydb; UID=andrew; PASSWORD=kh12345; OPTION=3" Dim connectme As OdbcConnection = New OdbcConnection(connectionstring) Dim sqlquery As String = "SELECT f_name, f_price from tbl_picture WHERE f_ID = 1" Dim ODBCdataadapter As OdbcDataAdapter = New OdbcDataAdapter(sqlquery, connectme) Dim ODBCdataset As DataSet = New DataSet() ODBCdataadapter.Fill(ODBCdataset) DataTable.DataSource = ODBCdataset DataTable1.DataSource = ODBCdataset Datatable.DataBind() Datatable1.DataBind() End Sub </SCRIPT > <ASP:Datagrid ID="Datatable1" Runat="server" AutoGenerateColumns="False"BorderStyle="None" GridLines="None"> <Columns> <asp:BoundColumn DataField="f_price" ReadOnly="True"/> </columns> </asp:DataGrid>
and here's the calculation part
Private Sub CalculatePayment() Dim c_loan_amount, c_Payment Dim amount As String = Datatable1.Select("f_price") c_loan_amount = amount - (amount * Down.Text * 0.01) c_Payment = ((c_loan_amount * (Interest.Text * 0.01) * Year.Text) + c_loan_amount) / (Year.Text * 12) Payment.Text = "RM " & Format(c_Payment, "#,##0.00") End Sub
It should be the Dim amount as string part right? I'm kinda new, thanks in advance.
原文:https://stackoverflow.com/questions/19855638
更新时间:2023-05-03 17:05
最满意答案
我很幸运能够迅速找到答案。 php.ini限制为20个文件上传。
I've thankfully managed to find the answer quickly. php.ini was limited to 20 file uploads.
相关问答
更多-
请帮忙测试一下“裘会强”这个名字能得多少分[2022-10-05]
20 -
遇到这样的问题时,请尝试找到最佳解决方案。 在这种情况下,您可以确定除了两个地方以外的所有地方都需要逗号,并且在一个地方都需要和号。 因此,不要为每个数组索引设置条件,而应该为逗号添加一个,为&符号添加一个: @foreach ($copy as $user => $value) {{$value->username}} // Place commas after all but the last two items @if ($user < count($copy) - 2) ...
-
循环中的迭代(Iterations In From Loop)[2024-02-22]
你可以使用STEP : for x = 0 to 100 step 10 next x 这将带你通过0, 10, 20... 100 既然你想从1开始,去1, 10, 20... 100 ,这里稍作修改 for x = 0 to 100 step 10 if x = 0 then y = 1 else y = x end if '// use y in all calculations downstream instead of x ... -
我解决了我的问题 {!! Form::select('subkategori',$sktgr,['style'=>'width:100%','data-toggle'=>'select2']) !!} I solved my problem {!! Form::select('subkategori',$sktgr,['style'=>'width:100%','data-toggle'=>'select2']) !!}
-
循环中的迭代次数(Number of iterations in a loop)[2022-01-19]
在Matlab中,无论你对for循环中的循环索引变量( a )做什么都会被抛弃,并且在下一遍开始时会重置a 。 所以循环内的a = a + 1没有效果。 请参阅MATLAB中是否存在foreach? 如果是这样,如果基础数据发生变化,它的表现如何? 。 In Matlab, whatever you do to the loop index variable (a) inside a for loop is thrown away, and a gets reset at the beginning of ... -
你应该用一个简单的:class元素绑定它: primary You should bind it with a simple :class element: primary
-
我很幸运能够迅速找到答案。 php.ini限制为20个文件上传。 I've thankfully managed to find the answer quickly. php.ini was limited to 20 file uploads.
-
Laravel Blade爆炸HTML(Laravel Blade Explode Html)[2023-08-02]
你的问题有两个可能的问题。 1)检查刀片文件。 它应该像filename.blade.php 2)你的阵列有一些问题。 如果您的数组是对象数组,则应该打印出{{ $key->yourValue }} 。 否则, {{ $key['yourValue'] }} 如果您提供阵列样本,我们可以为您的问题提供更好的答案。 希望这有帮助! 我想建议你编码标准的一件事。 根据PSR标准,您应该遵循PSR标准。 我不建议像$History那样声明。 它应该像$history 。 你可以从这里参考 改变这个 @forea ... -
从didUpdateLocations设置currentLocation var currentLocation : CLLocation?{ didSet{ evaluateClosestRegions() } } var allRegions : [CLRegion] = [] // Fill all your regions 现在计算并找到距离当前位置最近的区域,并仅跟踪这些区域。 func evaluateClosestRegions() { var a ...
-
迭代时限制%do%(limit %do %while iterations)[2021-10-12]
以下是您可以使用的示例: %macro mf; %let i=0; %do %until(&onechar=e or &i=10); %let i=%eval(&i+1); %let onechar=%substr(abcdefghij,&i,1); %end; %put onechar=&onechar; %put i=&i; %mend mf; %mf; 如果宏循环找到“e”或i = 10,则宏循环停止。 The following is an example of ...