C# to php to mysql -
C# to php to mysql -
i running server mysql database on it. making c# programme has set info database. security reasons send info php script inserts info in local mysql database.
i trying code below, when utilize fiddler check if url called, doesn't show up, seems if url never called.
my code looks this:
string result = string.empty; string data2 = string.empty; string[] postdata = new string[8]; postdata[0] = "date"; postdata[1] = log.endtime.tostring(); postdata[2] = "name"; postdata[3] = log.ownertask.schedule.name; postdata[4] = "status"; postdata[5] = log.parsedstatus; postdata[6] = "message"; postdata[7] = log.parsedmessage; string url = "http://x.x.x.x/send.php"; system.text.asciiencoding ascii = new asciiencoding(); (int = 0; < postdata.length; += 2) { data2 += string.format("&{0}={1}", postdata[i], postdata[i + 1]); } data2 = data2.remove(0, 1); byte[] bytesarr = ascii.getbytes(data2); seek { httpwebrequest request = (httpwebrequest)webrequest.create(url); request.method = "post"; request.contenttype = "application/x-www-form-urlencoded"; request.contentlength = bytesarr.length; system.io.stream streamwriter = request.getrequeststream(); streamwriter.write(bytesarr, 0, bytesarr.length); streamwriter.close(); }
can help me out? point me in right direction?
thanks
more focused answer, based on spot-on comment provided
after writing stream, should invoke getresponsestream
perform request:
system.io.stream streamwriter = request.getrequeststream(); streamwriter.write(bytesarr, 0, bytesarr.length); streamwriter.close(); var response = request.getresponsestream(); // execute request // [go on ...] }
old answer, spotted issue missed purpose of op code, left reference
i'm not able @ moment verify in vs this
system.io.stream streamwriter = request.getrequeststream(); ^^^^^^^
should be
system.io.stream streamwriter = request.getresponsestream(); ^^^^^^^^
as in: want parse response, not request (which code never executes, that's why don't see url beingness hit).
c# mysql
Comments
Post a Comment