Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ASP.NET
<div ng-app="MyApp" ng-controller="MyController">
    <h4>Customers</h4>
    <hr/>
    <table cellpadding="0" cellspacing="0">
        <tr>
            <th>symbol</th>
            <th>bidPrice</th>
            <th>bidQty</th>
        </tr>
        <tbody ng-repeat="m in Customers">
            <tr>
                <td>{{m.symbol}}</td>
                <td>{{m.bidPrice}}</td>
                <td>{{m.bidQty}}</td>
            </tr>
        </tbody>
    </table>
</div>
        
<script type="text/javascript">
    var app = angular.module('MyApp', [])
    app.controller('MyController', function ($scope, $http, $window) {
        var get = $http({
            method: "GET",
            url: "https://api3.binance.com/api/v3/ticker/bookTicker"
        });

        get.success(function (data, status) {
            $scope.Customers = data;
        });

        get.error(function (data, status) {
            $window.alert(data.Message);
        });
    });
</script>


What I have tried:

C#
string sql = "INSERT INTO NameTable (symbol,bidPrice,bidQty) VALUES (@symbol,@bidPrice,@bidQty)";
   using (SqlCommand command = new SqlCommand(sql, conn))
   {
       command.Parameters.AddWithValue("@symbol", "symbol");
       command.Parameters.AddWithValue("@bidPrice", "bidPrice");
       command.Parameters.AddWithValue("@bidQty", "bidQty");
       command.ExecuteNonQuery();
   }
Posted
Updated 28-Aug-23 9:26am
v2

Probably, you need to change this:
C#
command.Parameters.AddWithValue("@symbol", "symbol");
command.Parameters.AddWithValue("@bidPrice", "bidPrice");
command.Parameters.AddWithValue("@bidQty", "bidQty");
To this:
C#
command.Parameters.AddWithValue("@symbol", symbol);
command.Parameters.AddWithValue("@bidPrice", bidPrice);
command.Parameters.AddWithValue("@bidQty", bidQty);
 
Share this answer
 
Comments
Richard Deeming 29-Aug-23 4:20am    
And probably clear out the parameters collection after executing the query. :)
OriginalGriff 29-Aug-23 5:15am    
Hey, one problem at a time ... :D

It's in a using block, so the whole command will be Disposed when finished with, which will Dispose the parameters etc.
You haven't provided enough information. You didn't describe a problem you're having with this code, not any error messages.

The HTML/Javscript code you posted makes no attempt to call a controller method to put any data in the database and the SQL code you posted is incomplete so it's pretty much impossible to tell you what's going on and why.

One thing I will say is your parameters code is trying to insert the strings "symbol", "bidPrice", and "bidQty" into the database, not any actual data.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900