title: Blazor database connection to remote mysql server
body: <p>I'm briefly new into Blazor. I was wondering if it's possible to make a very basic connection to mysql database server hosted remotely via simple function:</p>
  <pre><code>string connectionString = &quot;data source = database ip here,1600;Initial Catalog=HDSERVER;Persist Security Info=True; User ID=user_id; Password=Password()&quot;;
  
      int idUser = -1;
  
      UserModel User = new UserModel();
  
      public class UserModel
      {
          public string name { get; set; }
          public string pin { get; set; }
      }
  
      private void LoginUser()
      {
          Console.WriteLine(User.name);
          Console.WriteLine(User.pin);
          {
              try
              {
                  Console.WriteLine(&quot;starting sql connection...&quot;);
  
                  SqlConnection c = new SqlConnection(connectionString);
  
                  Console.WriteLine(&quot;opening..&quot;);
  
                  c.Open();
  
                  Console.WriteLine(&quot;sql connection open..&quot;);
  
                  SqlCommand cmd = new SqlCommand(&quot;Login&quot;, c);
                  cmd.CommandType = CommandType.StoredProcedure;
                  cmd.Parameters.AddWithValue(&quot;@pin&quot;, pinCode);
  
                  Console.WriteLine(&quot;getting data&quot;);
  
                  var pId = cmd.Parameters.AddWithValue(&quot;@idUser&quot;, idUser);
  
                  Console.WriteLine(&quot;pId: &quot;, pId);
  
                  pId.Direction = ParameterDirection.Output;
  
                  cmd.ExecuteNonQuery();
                  c.Close();
  
                  Console.WriteLine(&quot;sql connection closed..&quot;);
  
                  int id = (int)pId.Value;
  
                  Console.WriteLine(&quot;id: &quot;, id);
  
                  if (id &gt; 0)
                  {
                      NavigationManager.NavigateTo(&quot;/home&quot;);
                  }
                  else
                  {
                      Console.WriteLine(&quot;Cannot sing in!&quot;);
                  }
              }
              catch (Exception e)
              {
                  Console.WriteLine(&quot;Error: &quot;);
                  Console.WriteLine(e.Message);
              }
          }
      }
  </code></pre>
  <p>Or maybe there is another specific way for doing that? I usually typing code in js &amp; react, so for me everything here is so new and a little confusing me. It would be great as well if someone could share any tips how to do such things or from where getting a knowledge about Blazor !</p>
  <p>Thanks in advance!</p>