|
-
Jul 17th, 2007, 11:23 AM
#1
Thread Starter
PowerPoster
[RESOLVED] POST string to webapge
Hey guys I have been trying to find a solution for this and I haven't run across anything helpfull so hopefully you can help me here.
This is a windows app not an ASP web app, if that matters.
I am trying to use something like this to POST a string to a webpage on my server. Is this possible from a windows app? I have no idea how to go about it and can't seem to find anything that is helping.
Code:
string sql = "INSERT INTO tblWhatever (field1,field2) VALUES ('1','2')";
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("");
myReq.Method = "POST";
myReq.ContentType = "application/x-www-form-urlencoded";
StreamWriter writer = new StreamWriter(myReq.GetRequestStream());
writer.Write(sql);
writer.Close();
Alternatively, I have one function that checks to see if an account ID is valid. I would like to send the AccountID to a webapge on my server, have the webpage see if the account is valid then send back a response of "yes or no" to my windows app. Is that possible?
Thanks for any input you can give me!
Last edited by Arc; Mar 14th, 2008 at 06:12 PM.
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Jul 17th, 2007, 02:15 PM
#2
Re: POST string to webapge
Why not use a web-service instead. it's type safe and more reliable than this method
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 17th, 2007, 02:19 PM
#3
Thread Starter
PowerPoster
Re: POST string to webapge
A web service? I am not even sure what that is. Would that have to be a completely different program or can I integrate it into this Windows app?
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Jul 17th, 2007, 02:34 PM
#4
Re: POST string to webapge
 Originally Posted by Arc
A web service? I am not even sure what that is. Would that have to be a completely different program or can I integrate it into this Windows app?
The web service is like a web accessed class library. it can contain methods to be called (executed) remotely and return values. You can google a better definition.
You can include it in your website and reference it from the Windows App
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 17th, 2007, 03:36 PM
#5
Thread Starter
PowerPoster
Re: POST string to webapge
My website is made with PHP not asp.net...hrmm
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Jul 17th, 2007, 03:48 PM
#6
I wonder how many charact
Re: POST string to webapge
This search for 'Arc' works with VBForums (which is a php site 
Code:
static void Main(string[] args)
{
string values =
"do=process&showposts=0&quicksearch=1&s=&query=Arc";
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://www.vbforums.com/search.php");
myReq.Method = "POST";
myReq.ContentType = "application/x-www-form-urlencoded";
StreamWriter writer = new StreamWriter(myReq.GetRequestStream());
writer.Write(values);
writer.Close();
HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
Stream stream = myResp.GetResponseStream();
StreamReader reader = new StreamReader(stream);
string response = reader.ReadToEnd();
Console.WriteLine(response);
Console.ReadLine();
}
-
Jul 17th, 2007, 06:12 PM
#7
Thread Starter
PowerPoster
Re: POST string to webapge
That seems to be working perfectly. Thanks so much for the help!
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|