我收到该Url
值的强制转换错误。有谁知道如何将值转换为包含多种值类型的字符串?
CmdRecipients = new OleDbCommand(QueryRecipients, ConnRecipients);
Recipients = CmdRecipients.ExecuteReader();
while (Recipients.Read())
{
Url = "https://bulktext.vodafone.ie/sendmessage.aspx"
+ "?user=user&password=user1!&api_id=89&to="
+ Recipients.GetString(8)
+ "&text=" + Confirmations.GetString(4)
+ "%0d%0a" + Confirmations.GetString(5)
+ "%0d%0a" + Confirmations.GetString(6)
+ "&from=Service";
Console.Write("Sending text to " + Recipients.GetString(8) + " ... ");
//Send SMS Here
HttpWebRequest req = WebRequest.Create(Url) as HttpWebRequest;
string result = null;
using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(resp.GetResponseStream());
result = reader.ReadToEnd();
if (result == "0\nRequest deferred successfully")
{
QueryRecipients = "UPDATE [Test].[dbo].[MessagesToSend] SET Previous_Status = Current_Status,"
+ "Current_Status = \"Sent\", DateTime_sent = Now() "
+ "WHERE Task_ID = \"" + Recipients.GetString(2) + "\";";
OleDbCommand Update = new OleDbCommand(QueryRecipients, ConnConfirmations);
Update.ExecuteNonQuery();
Console.WriteLine("Done!");
}
else
{
Console.WriteLine("The text wasn't delivered properly.");
}
}
}