i working on universal windows applications, in 1 of project want connect azure sql database, added below code using sqlconenction
class.
try { sqlconnection connection = null; string query = null; //datetime datetime = datetime.now; connection = new sqlconnection("data source=xxxxx.database.windows.net;initial catalog=xxxxx_db;integrated security=false;user id=xxxxx;password=xxxxx;connect timeout=60;encrypt=false;trustservercertificate=true;applicationintent=readwrite;multisubnetfailover=false"); connection.open(); // converts image file byte[] // byte[] imgdata = file.readallbytes(app.m_photostoragefile.path); query = "insert [dbo].[delivery_analytics.xxxxxx] (name,mobilenumber,companyname,deliveryaddress,image,timestamp)" + "values ('" + nametxtbx.text + "','" + mobilenumtxtbx.text + "','" + comapanynametxtbx.text + "','" + deliveryaddress + "','" + picturetxtbx.text + "','" + datetime + "')"; using (sqlcommand cmd = new sqlcommand(query, connection)) { cmd.executenonquery(); connection.close(); } } catch (exception ex) { }
but when trying open sqlconnection
got below exception.
could not load file or assembly
system.threading.thread, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a
or 1 of dependencies. system cannot find file specified.
please tell me how resolve issue.
sqlconnection not windows runtime/uwp, that's why got exception.
we can not access sql server database uwp app directly, have create service layer access database.
the right way create web service , our app can consume retrieve data.
for example, can choose azure app service.
Comments
Post a Comment