Problème avec Excel-Dna et C#
soufian
-
soufian -
soufian -
Hi,
I am currently working on a program in C# which is looking for datas in a database with an excel-DNA addin. To simplify I have two columns in the SQL database, one is ID the other is Isin. I need an excel plugin in which I put he isin to get the id. (the program has other goals but my first problem is there). Please help me, I am getting crazy !
So here is my class :
And then I have my addin.dna :
There are no errors on visual studio but it doesn't work. Excel returns : "NAME?"
Anyone can help please?
I am currently working on a program in C# which is looking for datas in a database with an excel-DNA addin. To simplify I have two columns in the SQL database, one is ID the other is Isin. I need an excel plugin in which I put he isin to get the id. (the program has other goals but my first problem is there). Please help me, I am getting crazy !
So here is my class :
public class MyFunctionsOk then I have another class DBSQL with the connection to the server and the getid function :
{
DBSQL B=new DBSQL(); // (here I have an object with the function get id and the connection to the server, I have this on another layer which is OK I think)
[ExcelFunction(Description = "fonction de recherche")]
public string idCL(string _isin)
//module excel
{
String res;
B.Connection();
res= "id= " + B.getID(_isin);
// (getID is in DBSQL)
B.CloseConnection();
return res;
}
}
public long getID(String _isin)
{
SqlDataReader rd;
long res = -9999;
SqlCommand cd = new SqlCommand("select astid from blabla where isin='" + _isin + "'", MaConn);
//requète au serveur
try
{
rd = cd.ExecuteReader();
if (rd.HasRows)
{
while (rd.Read())
res = long.Parse(rd["astid"].ToString());
}
And then I have my addin.dna :
<DnaLibrary Name="ClassLibrary Add-In" RuntimeVersion="v4.0">
<ExternalLibrary Path="ClassLibrary1.dll" LoadFromBytes="true" Pack="true" />
<Reference Path="AccesDB.dll" Pack="true" />
</DnaLibrary>
There are no errors on visual studio but it doesn't work. Excel returns : "NAME?"
Anyone can help please?
A voir également:
- Problème avec Excel-Dna et C#
- Liste déroulante excel - Guide
- Word et excel gratuit - Guide
- Déplacer colonne excel - Guide
- Si ou excel - Guide
- Excel moyenne - Guide