How to connect SQL Server with Unity?











up vote
0
down vote

favorite












I am trying to store or retrieve an image dynamically using Unity from SQL Server. I am facing issues trying to connect to the SQL Server. How do I connect to the SQL Server?










share|improve this question









New contributor




satvika Bhogavalli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • First of all try your own code, and if you have any problem, put your code here.
    – Siavash
    yesterday










  • I think Unity can't be used for that purpose, something else will be needed for getting the data from SqlServer and then use that data with Unity. As an example there's SqlConnection class docs.microsoft.com/en-us/dotnet/api/…
    – rvazquezglez
    yesterday










  • A minimal complete and verifiable example would really help
    – Fabjan
    yesterday















up vote
0
down vote

favorite












I am trying to store or retrieve an image dynamically using Unity from SQL Server. I am facing issues trying to connect to the SQL Server. How do I connect to the SQL Server?










share|improve this question









New contributor




satvika Bhogavalli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • First of all try your own code, and if you have any problem, put your code here.
    – Siavash
    yesterday










  • I think Unity can't be used for that purpose, something else will be needed for getting the data from SqlServer and then use that data with Unity. As an example there's SqlConnection class docs.microsoft.com/en-us/dotnet/api/…
    – rvazquezglez
    yesterday










  • A minimal complete and verifiable example would really help
    – Fabjan
    yesterday













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am trying to store or retrieve an image dynamically using Unity from SQL Server. I am facing issues trying to connect to the SQL Server. How do I connect to the SQL Server?










share|improve this question









New contributor




satvika Bhogavalli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I am trying to store or retrieve an image dynamically using Unity from SQL Server. I am facing issues trying to connect to the SQL Server. How do I connect to the SQL Server?







c# sql-server unity3d






share|improve this question









New contributor




satvika Bhogavalli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




satvika Bhogavalli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday









Dungeon

19511




19511






New contributor




satvika Bhogavalli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









satvika Bhogavalli

1




1




New contributor




satvika Bhogavalli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





satvika Bhogavalli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






satvika Bhogavalli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • First of all try your own code, and if you have any problem, put your code here.
    – Siavash
    yesterday










  • I think Unity can't be used for that purpose, something else will be needed for getting the data from SqlServer and then use that data with Unity. As an example there's SqlConnection class docs.microsoft.com/en-us/dotnet/api/…
    – rvazquezglez
    yesterday










  • A minimal complete and verifiable example would really help
    – Fabjan
    yesterday


















  • First of all try your own code, and if you have any problem, put your code here.
    – Siavash
    yesterday










  • I think Unity can't be used for that purpose, something else will be needed for getting the data from SqlServer and then use that data with Unity. As an example there's SqlConnection class docs.microsoft.com/en-us/dotnet/api/…
    – rvazquezglez
    yesterday










  • A minimal complete and verifiable example would really help
    – Fabjan
    yesterday
















First of all try your own code, and if you have any problem, put your code here.
– Siavash
yesterday




First of all try your own code, and if you have any problem, put your code here.
– Siavash
yesterday












I think Unity can't be used for that purpose, something else will be needed for getting the data from SqlServer and then use that data with Unity. As an example there's SqlConnection class docs.microsoft.com/en-us/dotnet/api/…
– rvazquezglez
yesterday




I think Unity can't be used for that purpose, something else will be needed for getting the data from SqlServer and then use that data with Unity. As an example there's SqlConnection class docs.microsoft.com/en-us/dotnet/api/…
– rvazquezglez
yesterday












A minimal complete and verifiable example would really help
– Fabjan
yesterday




A minimal complete and verifiable example would really help
– Fabjan
yesterday












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Unity uses the MONO.NET framework, which is very similar to the Microsoft.NET framework.
This is sample code:



public void connect(){
string connectionString =
"Server=servername;" +
"Database=dbname;" +
"User ID=userid;" +
"Password=pass;" +
"Integrated Security=True";

result = new List<float> ();
resultCas = new List<DateTime> ();

using(SqlConnection conn = new SqlConnection(connectionString))
{
SqlCommand c; SqlDataReader da; SqlParameter param1; SqlParameter param2; SqlParameter param3; SqlParameter param4;
conn.Open();
c = new SqlCommand();
c.Connection = conn;
c.CommandType = CommandType.StoredProcedure;
c.CommandText = "commandtext";
param1 = c.Parameters.Add("@identify",SqlDbType.Int);
param1.Value = 1;
param2 = c.Parameters.Add("@startTime",SqlDbType.DateTime);
param2.Value = "2010-11-10 07:45:00.000";
param3 = c.Parameters.Add("@endTime",SqlDbType.DateTime);
param3.Value = "2010-11-12 10:15:00.000";
param4 = c.Parameters.Add("@args",SqlDbType.NVarChar);
param4.Value = "I";
da = c.ExecuteReader();
while (da.Read())
{
resultCas.Add(da.GetDateTime(0));
result.Add((float)da.GetDouble(1));
}
}
}


From Unity, use the WWW or UnityWebRequest class to communicate with that script and then, you will be able to send and receive information from Unity to the server. There are many examples out there.
You can also receive data multiple with json.



Visit this complete example from this Unity wiki. It shows how to interact with a database in Unity using php and C# on the server side and Unity on the client side.



Hope it Helps.Thanks!






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    satvika Bhogavalli is a new contributor. Be nice, and check out our Code of Conduct.










     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405220%2fhow-to-connect-sql-server-with-unity%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Unity uses the MONO.NET framework, which is very similar to the Microsoft.NET framework.
    This is sample code:



    public void connect(){
    string connectionString =
    "Server=servername;" +
    "Database=dbname;" +
    "User ID=userid;" +
    "Password=pass;" +
    "Integrated Security=True";

    result = new List<float> ();
    resultCas = new List<DateTime> ();

    using(SqlConnection conn = new SqlConnection(connectionString))
    {
    SqlCommand c; SqlDataReader da; SqlParameter param1; SqlParameter param2; SqlParameter param3; SqlParameter param4;
    conn.Open();
    c = new SqlCommand();
    c.Connection = conn;
    c.CommandType = CommandType.StoredProcedure;
    c.CommandText = "commandtext";
    param1 = c.Parameters.Add("@identify",SqlDbType.Int);
    param1.Value = 1;
    param2 = c.Parameters.Add("@startTime",SqlDbType.DateTime);
    param2.Value = "2010-11-10 07:45:00.000";
    param3 = c.Parameters.Add("@endTime",SqlDbType.DateTime);
    param3.Value = "2010-11-12 10:15:00.000";
    param4 = c.Parameters.Add("@args",SqlDbType.NVarChar);
    param4.Value = "I";
    da = c.ExecuteReader();
    while (da.Read())
    {
    resultCas.Add(da.GetDateTime(0));
    result.Add((float)da.GetDouble(1));
    }
    }
    }


    From Unity, use the WWW or UnityWebRequest class to communicate with that script and then, you will be able to send and receive information from Unity to the server. There are many examples out there.
    You can also receive data multiple with json.



    Visit this complete example from this Unity wiki. It shows how to interact with a database in Unity using php and C# on the server side and Unity on the client side.



    Hope it Helps.Thanks!






    share|improve this answer

























      up vote
      0
      down vote













      Unity uses the MONO.NET framework, which is very similar to the Microsoft.NET framework.
      This is sample code:



      public void connect(){
      string connectionString =
      "Server=servername;" +
      "Database=dbname;" +
      "User ID=userid;" +
      "Password=pass;" +
      "Integrated Security=True";

      result = new List<float> ();
      resultCas = new List<DateTime> ();

      using(SqlConnection conn = new SqlConnection(connectionString))
      {
      SqlCommand c; SqlDataReader da; SqlParameter param1; SqlParameter param2; SqlParameter param3; SqlParameter param4;
      conn.Open();
      c = new SqlCommand();
      c.Connection = conn;
      c.CommandType = CommandType.StoredProcedure;
      c.CommandText = "commandtext";
      param1 = c.Parameters.Add("@identify",SqlDbType.Int);
      param1.Value = 1;
      param2 = c.Parameters.Add("@startTime",SqlDbType.DateTime);
      param2.Value = "2010-11-10 07:45:00.000";
      param3 = c.Parameters.Add("@endTime",SqlDbType.DateTime);
      param3.Value = "2010-11-12 10:15:00.000";
      param4 = c.Parameters.Add("@args",SqlDbType.NVarChar);
      param4.Value = "I";
      da = c.ExecuteReader();
      while (da.Read())
      {
      resultCas.Add(da.GetDateTime(0));
      result.Add((float)da.GetDouble(1));
      }
      }
      }


      From Unity, use the WWW or UnityWebRequest class to communicate with that script and then, you will be able to send and receive information from Unity to the server. There are many examples out there.
      You can also receive data multiple with json.



      Visit this complete example from this Unity wiki. It shows how to interact with a database in Unity using php and C# on the server side and Unity on the client side.



      Hope it Helps.Thanks!






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Unity uses the MONO.NET framework, which is very similar to the Microsoft.NET framework.
        This is sample code:



        public void connect(){
        string connectionString =
        "Server=servername;" +
        "Database=dbname;" +
        "User ID=userid;" +
        "Password=pass;" +
        "Integrated Security=True";

        result = new List<float> ();
        resultCas = new List<DateTime> ();

        using(SqlConnection conn = new SqlConnection(connectionString))
        {
        SqlCommand c; SqlDataReader da; SqlParameter param1; SqlParameter param2; SqlParameter param3; SqlParameter param4;
        conn.Open();
        c = new SqlCommand();
        c.Connection = conn;
        c.CommandType = CommandType.StoredProcedure;
        c.CommandText = "commandtext";
        param1 = c.Parameters.Add("@identify",SqlDbType.Int);
        param1.Value = 1;
        param2 = c.Parameters.Add("@startTime",SqlDbType.DateTime);
        param2.Value = "2010-11-10 07:45:00.000";
        param3 = c.Parameters.Add("@endTime",SqlDbType.DateTime);
        param3.Value = "2010-11-12 10:15:00.000";
        param4 = c.Parameters.Add("@args",SqlDbType.NVarChar);
        param4.Value = "I";
        da = c.ExecuteReader();
        while (da.Read())
        {
        resultCas.Add(da.GetDateTime(0));
        result.Add((float)da.GetDouble(1));
        }
        }
        }


        From Unity, use the WWW or UnityWebRequest class to communicate with that script and then, you will be able to send and receive information from Unity to the server. There are many examples out there.
        You can also receive data multiple with json.



        Visit this complete example from this Unity wiki. It shows how to interact with a database in Unity using php and C# on the server side and Unity on the client side.



        Hope it Helps.Thanks!






        share|improve this answer












        Unity uses the MONO.NET framework, which is very similar to the Microsoft.NET framework.
        This is sample code:



        public void connect(){
        string connectionString =
        "Server=servername;" +
        "Database=dbname;" +
        "User ID=userid;" +
        "Password=pass;" +
        "Integrated Security=True";

        result = new List<float> ();
        resultCas = new List<DateTime> ();

        using(SqlConnection conn = new SqlConnection(connectionString))
        {
        SqlCommand c; SqlDataReader da; SqlParameter param1; SqlParameter param2; SqlParameter param3; SqlParameter param4;
        conn.Open();
        c = new SqlCommand();
        c.Connection = conn;
        c.CommandType = CommandType.StoredProcedure;
        c.CommandText = "commandtext";
        param1 = c.Parameters.Add("@identify",SqlDbType.Int);
        param1.Value = 1;
        param2 = c.Parameters.Add("@startTime",SqlDbType.DateTime);
        param2.Value = "2010-11-10 07:45:00.000";
        param3 = c.Parameters.Add("@endTime",SqlDbType.DateTime);
        param3.Value = "2010-11-12 10:15:00.000";
        param4 = c.Parameters.Add("@args",SqlDbType.NVarChar);
        param4.Value = "I";
        da = c.ExecuteReader();
        while (da.Read())
        {
        resultCas.Add(da.GetDateTime(0));
        result.Add((float)da.GetDouble(1));
        }
        }
        }


        From Unity, use the WWW or UnityWebRequest class to communicate with that script and then, you will be able to send and receive information from Unity to the server. There are many examples out there.
        You can also receive data multiple with json.



        Visit this complete example from this Unity wiki. It shows how to interact with a database in Unity using php and C# on the server side and Unity on the client side.



        Hope it Helps.Thanks!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        Dungeon

        19511




        19511






















            satvika Bhogavalli is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            satvika Bhogavalli is a new contributor. Be nice, and check out our Code of Conduct.













            satvika Bhogavalli is a new contributor. Be nice, and check out our Code of Conduct.












            satvika Bhogavalli is a new contributor. Be nice, and check out our Code of Conduct.















             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405220%2fhow-to-connect-sql-server-with-unity%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)