Xamarin Sql Server无法获得连接

问题描述 投票:0回答:2

我使用xamarin上的实体框架构建一个应用程序,我可以比较一些数据。但是,当我启动我的“fetchdata”功能时,我发现了错误:

System.Data.SqlClient.SqlException (0x80131904): Snix_Connect (provider: SNI_PN7, error: 35 - SNI_ERROR_35)Snix_Connect (provider: SNI_PN7, error: 35 - SNI_ERROR_35) 

现在我的洞设置准备就绪,我看到很多关于xamarin / android的帖子,并且无法获得与SqlServer的连接。但是时间过去了,所以我希望有可能。

有没有办法从xamarin上的.net核心的sqlServer获取数据?

android .net sql-server xamarin core
2个回答
0
投票

这是我用Sql_Common.cs放入SQL_Class文件夹的字符串 用实际参数填充支架(也可以拆下支架)。

public static string SQL_connection_string = @"data source={server_address};initial catalog={database_name};user id={user_id};password={password};Connect Timeout={seconds}";

然后我就可以从任何xamarin代码中访问它,就像我们在asp.net中使用的那样# 这适用于我的应用程序没有任何问题。

using (SqlConnection Sql_Connection = new SqlConnection(Sql_Common.saralEHR_connection_string))

但正如@Jason在他的第一个回复中提到的,我也会再次检查安全部分。我在将Package发布到Google Play之前经验丰富,他们使用Hash Key Code对App文件进行加密,然后才上传到服务器


0
投票

是的,这是可能的(HuurrAYY!):我是.net核心的新手,c#等等,对我来说,让它工作是一件很棒的工作..所以这里寻找帮助的其他新手:

我使用的指南:使用实体框架https://medium.com/@yostane/data-persistence-in-xamarin-using-entity-framework-core-e3a58bdee9d1 https://blog.xamarin.com/building-android-apps-entity-framework/构建Android应用程序

脚手架https://cmatskas.com/scaffolding-dbcontext-and-models-with-entityframework-core-2-0-and-the-cli/

我是怎么做到的:

  1. 构建您的普通Xamarin应用程序。
  2. 创建新的.net解决方案,就像在教程中一样(不要写你的实体框架CLASSES)
  3. 创建一个必须是.net核心控制台应用程序的第三个解决方案
  4. 在您的CONSOLE应用程序中支持您的数据库在“xamarin .net”解决方案中移动所有创建的类和文件夹并更改命名空间
  5. 准备好出发!

侧节点:每个解决方案中都需要NuGets:

  • Microsoft.EntityFrameworkCore
  • Microsoft.EntityFrameworkCore.SqlServer

[编辑:每个解决方案都需要NuGets]

© www.soinside.com 2019 - 2024. All rights reserved.