c# - ASP.NET use data retrieved from SQL in API weblink/Weblink -


im trying use data im storing in sql db , put api weblink;

the link im trying data is:

https://api.eveonline.com/account/characters.xml.aspx?keyid=[sqldata]&&vcode=[othersqldata] 

so clear @ end of want this:

    https://api.eveonline.com/account/characters.xml.aspx?keyid=[123]&&vcode=[1234] 

i'm having trouble don't know how data sql , enter weblink.

here code;

            sqlconnection conn = null;          try         {             string sql = "select apikey, verif dbo.users username = @username";              conn = new sqlconnection(configurationmanager.connectionstrings["reader"].connectionstring);              sqlcommand cmd = new sqlcommand(sql, conn);              sqlparameter usern = new sqlparameter();             usern.parametername = "@username";             usern.value = user.identity.name;             cmd.parameters.add(usern);              conn.open();             cmd.executenonquery();         }                 {             if (conn.state == system.data.connectionstate.open)                 conn.close();         }     } 

this query not non-query, replace execute with:

sqldatareader reader = cmd.executereader(); 

then data with:

string url;  if (reader.hasrows) {     url = string.format(         "https://api.eveonline.com/account/characters.xml.aspx?keyid=[{0}]&&vcode=[{1}]",         reader.getstring(0),         reader.getstring(1)); } else {     url = null; // username not found } 

now have url or null, if initial username wrong. if print out url should valid url expected.


Comments