Probleme avec ma classe de connexion
Bonjourà tous,
Je suis débutant en asp.net et je veux créer une classe de connexion à ma BD mysql en utilisant ODBC. Pour cela j'ai télécharger une code écrit en vb.net sur le web que j'ai essayé de traduire en C#.
Le code est le suivant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| public OdbcDataReader myODBCreader(string ReqSql, string CnxStrings)
{
OdbcConnection myODBCConnexion = new OdbcConnection(CnxStrings);
try
{
OdbcCommand myCommand =new OdbcCommand();
OdbcDataReader myDataReader;
OdbcConnection.ReleaseObjectPool();
myODBCConnexion.Open();
myCommand.Connection=myODBCConnexion;
myCommand.CommandText= ReqSql;
myDataReader= myCommand.ExecuteReader(CommandBehavior.CloseConnection);
return (OdbcDataReader)result=myDataReader;
OdbcConnection.ReleaseObjectPool();
}
catch (OdbcException myODBCexception)
{
HttpContext.Current.Trace.Write(myODBCexception.ToString());
}
catch (Exception myException)
{
HttpContext.Current.Trace.Write(myException.ToString());
}
finally
{
if (myODBCConnexion != null )
{
myODBCConnexion.Close();
myODBCConnexion = null;
}
}
} |
A la compilation, j'ai l'erreur suivante:
The name 'result' does not exist in the current context
Merci de bien vouloir m'aider.