0

I have this problem

private void ContruirGrelha()
{
    SqlConnection conectar = new SqlConnection(Metodos.BaseDeDados);
    conectar.Open();
}

In Metodos.BaseDeDados it tells me that I:

Cannot convert from 'method group' to 'string'

public static partial class Metodos
{
    public static void BaseDeDados()
    {
        SqlConnection conectar = new SqlConnection(@"Data Source=DESKTOP-VJ9V9CM\SQLEXPRESS;Initial Catalog=Agenda;Integrated Security=True");
        conectar.Open();
        ...
    }
}

Metodos.BaseDeDados conect the SQL server to my programa, and he had all my data, he has all the contet of my SQL data base, and i want to use his conection and data in my "private void ConstruirGrelha()" to build a datagrid. Sorry for the bad english

G4ma
  • 1
  • 1
  • It's probably Metodos.BaseDeDados() <- a method not a property. – MikeJ Oct 23 '20 at 01:40
  • Duplicate contains explanation of the exact error (so at least future visitors searching for similar error get answer), but code in the question does not make much sense (in particular `new SqlConnection(Metodos.BaseDeDados)`), so it is hard to know which way you wanted it fixed. – Alexei Levenkov Oct 23 '20 at 01:45
  • Why are you using `Metodos.BaseDeDados` in `new SqlConnection`? – Chetan Oct 23 '20 at 02:03
  • Metodos.BaseDeDados conect the SQL server to my programa, and he had all my data, he has all the contet of my SQL data base, and i want to use his conection and data in my "private void ConstruirGrelha()" to build a datagrid. Sorry for the bad english – G4ma Oct 23 '20 at 07:17

0 Answers0