weixin_33688840 2018-06-11 04:30 采纳率: 0%
浏览 27


I'm using javascript to receive data from an arduino, to save the data on the database i'm using dapper and to test it i'm using postman.

Here's my javascript code for receiving the Json data. I'm compairing the names on my javascript code (which are use to receive the data) with the ones i'm using on my c# code that are mapped with my database, if the names match then save the data i just received in my database and post it on my website

 var Latitude = ("#Latitude").val();
    var Longitude = ("#Longitude").val();
    var Country = ("#Country").val();
    var ObtainedDate = ("#ObtainedDate").val();

    type: 'POST',
    url: 'http://localhost:59319/Home/Map',
    data: { Latitude: Latitude, Longitude: Longitude, Country: Country, ObtainedDate: ObtainedDate },
    dataType: "json",
    success: function (lctn) {
        $.each(lctn, function (i, lctns) {
            $lctn.append(lctns.Latitude + lctns.Longitude + lctns.Country + lctns.ObtainedDate)


Here's the code i used to connect to my data base

SqlConnection conn = new SqlConnection();

    public GeoDapperConnection()
        conn.ConnectionString = "Server=tcp:espejo.database.windows.net,1433;Initial Catalog=DbEspejo;Persist Security Info=False;User ID=IntecEspejo;Password=P@ssw0rd;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";

        var data = conn.Query<Geography>("SELECT * FROM GEOGRAPHY").ToList();

This is to show the data from my data base

public List<Geography> Locations()

        var data = conn.Query<Geography>("GET_LOCATION", null, commandType: System.Data.CommandType.StoredProcedure).ToList();


        return data;

And this code is to receive the data from the javascript part and send it to my database

public void ReceiveData(Geography Geo)
            var queryParameters = new DynamicParameters();
            queryParameters.Add("@Lat", Geo.Latitude);
            queryParameters.Add("@Long", Geo.Longitude);
            queryParameters.Add("@Country", Geo.Country);
            queryParameters.Add("@DateCreated", Geo.ObtainedDate);

            var data = conn.Query("INSERT_LOCATION", queryParameters, commandType: System.Data.CommandType.StoredProcedure);



Here's the json data i'm posting to my website Postman

Here's the picture of my website, it doesn't show me on my list my new data


And this is my Geography class

public class Geography
        public int RouteID { get; set; }

        public double Latitude { get; set; }
        public double Longitude { get; set; }

        public string ISO { get; set; }
        public string Country { get; set; }
        public string ISO3 { get; set; }

        public DateTime ObtainedDate { get; set; }
  • 写回答



      相关推荐 更多相似问题


      • ¥15 c++字符串分割问题
      • ¥15 关于#sql#的问题:没有用命令关闭cdc,手动把系统表开启的cdc右键删除了
      • ¥15 vue+uniapp
      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver
      • ¥15 审稿意见请教-用ERNIE进行小样本分类的对比实验问题