Bonjour j'ai un problème de connexion à ma base de données.
Voici le code!
private void button1_Click(object sender, EventArgs e)
{
sqlConnect = new SqlConnection();
sqlConnect.ConnectionString = "Data Source =" + Environment.MachineName + ";Initial Catalog = COMPTE;Integrated Security = true";
try
{
sqlConnect.Open();
sqlCde = new SqlCommand();
sqlCde.Connection = sqlConnect;
string strSql = "Select * from stg0224.NCOMPTE";
sqlCde.CommandType = CommandType.Text;
sqlCde.CommandText = strSql;
sqlRdr = sqlCde.ExecuteReader();
while (sqlRdr.Read())
{
int codeF = sqlRdr.GetInt16(0);
}
sqlRdr.Close();
}
catch
{
MessageBox.Show("Erreur de connexion à la base", "Connexion", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
finally
{
sqlConnect.Close();
}
}
L'erreur soulevée est la suivante:
Nom d'objet 'stg0224.NCOMPTE' non valide.
Merci à ceux qui sauront m'aider.
Partager