I am setting up a simple server, and am having some connection issues.
I know that there are others who have posted on this but I still cannot figure it out.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
namespace DormWeb
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
insertName.Text = ("Great job. You have figured out what your name is.");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection dormconn = new SqlConnection
("Server=tcp:dormwebserver.database.windows.net,1433;Initial Catalog=DormSQL;Persist" +
" Security Info=True;User ID=Josh@...................onmicrosoft.com;Password=...........;MultipleActiveRe" +
"sultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;");
{
SqlCommand insert = new SqlCommand("EXEC dbo.InsertFullname @Fullname", dormconn);
insert.Parameters.AddWithValue("@Fullname", insertName.Text);
dormconn.Open();
insert.ExecuteNonQuery();
dormconn.Close();
if (IsPostBack)
{
insertName.Text = "";
}
}
}
}
}
Has been attempted with VS logged in with Admin account for server, and secondary admin account, as per instructions.
I am logging into SQL management studio via active directory. Maybe that is my issue? Cannot get it to work when I opt in the active directory connection string.
Remove { and } around your user name and password.
In the connection string you get from Azure portal:
Server=tcp:jacksqldemo.database.windows.net,1433;Initial Catalog=sqldemo;Persist Security Info=False;User ID={your_username};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
{your_username} and {your_password} are just placeholders.
User contributions licensed under CC BY-SA 3.0