mardi 31 octobre 2017

Web api retrieving data form SQL server

i have never worked with web api before.

i have this problem where i want to read the tables in my database.

    ```// GET: api/test
    public IEnumerable<string> Get()
    {
        using(SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["myDB"].ConnectionString))
        {
            conn.Open();

            string query = "Select * from Werknemer";

            SqlCommand cmd = new SqlCommand(query, conn);
            SqlDataReader reader = cmd.ExecuteReader();

            return new string[] {  };
        }
    }```

this is what i have.... how do i return a table in my database?




Aucun commentaire:

Enregistrer un commentaire