im努力将一些数据插入到我的Azure SQL数据库中。 我可以通过Visual Studio中的sql Explorer连接接收我的数据。 但是现在我想通过APP(在Android 8.1 API 27上进行测试-使用Xamarin Live Player)向其中写入一些数据,这是我的代码(特定数据在我的连接字符串中带有*):
async void OnSignUpButtonClicked(object sender, EventArgs e)
{
var user = new Users()
{
Username = usernameEntry.Text,
Password = passwordEntry.Text,
Email = emailEntry.Text
};
string connStr = "Server=tcp:*;Initial Catalog=*;Persist Security Info=False;User ID=*;Password=*.;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
using (var conn = new SqlConnection(connStr))
{
using (var command = conn.CreateCommand())
{
command.CommandText = @"
INSERT dbo.users (Username, Password, Email)
VALUES (@Username, @Password, @Email)";
command.Parameters.AddWithValue("@Username", "Testuser");
command.Parameters.AddWithValue("@Password", "Testpass");
command.Parameters.AddWithValue("@Email", "Test@mail.com");
conn.Open();
int inserteduser = (int)command.ExecuteScalar();
conn.Close();
}
我不断收到错误消息,找不到1252数据编码。
我认为问题是,我的Azure SQL数据库的编码为SQL_Latin1_General_CP1_CI_AS,但是如何将数据转换为它?
还是其他问题呢?有想法吗?
编辑:错误不一样!