Has anybody had any luck with connecting to a SQL database hosted by azure?
I’m assuming the connection fails due to some missing authentication, but can’t really debug what’s missing or why I’m unable to connect and post data. The code posted below works on my computer, but not on the iMX6. The code below works for local SQL databases just fine. Thanks, Matt
using System.Data.SQLClient;
try
{
string connString = "Data Source=myDB.database.windows.net;Initial Catalog=databasename;User ID=******;Password=********";
string cmdText = "insert into dbo.dBEvents(LocName, LocDesc) values ('x','y');";
using (SqlConnection connection = new SqlConnection(connString))
{
connection.Open();
int inserQueryCheck = 0;
using (SqlCommand command = new SqlCommand(cmdText, connection))
{
inserQueryCheck = command.ExecuteNonQuery();
if (inserQueryCheck > 0)
{
MessageBox.Show("INSERTED");
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("FAILED");
}