The error is telling you that you can't convert a String into a SqlConnection. So, you are passing a string in as the second parameter to the SqlCommand constructor. You need to pass a SqlConnection, not just the Connection String.
SqlCommand Constructor (System.Data.SqlClient) | Microsoft Docs[
^]
However, the better approach is to use the using statement, something like this:
using (SqlConnection con = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand("SELECT ...", con))
{
}
}
This sample is in C#. But the main point is to pass the proper parameter.