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 :
public class MyFunctions {
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; } }
Ok then I have another class DBSQL with the connection to the server and the getid function :
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()); }