Wrox Programmer Forums
|
C# 4.0 aka C# 2010 General Discussion Discussions about the C# 4.0, C# 4, Visual C# 2010 language and tool not related to any specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 4.0 aka C# 2010 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2011, 04:07 AM
Authorized User
 
Join Date: Apr 2010
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default error 101 in asp.net??

i am using an sms api to send sms to a mobile phone.

here's my asp.net code:

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
string num = "91"+txtno.Text;
string msg = txtmessage.Text;
string url = "http://smslane.com/vendorsms/pushsms.aspx?user=harshilsh&password=may240586&msi sdn=" + num;
url += "&sid=WebSMS&msg=" + msg;
url += "&fl=0";
Uri uri = new Uri(url);
WebRequest request = WebRequest.Create(uri);
WebResponse response = request.GetResponse();
//String ver = response.ResponseUri();
StreamReader reader = new StreamReader(response.GetResponseStream());
string str = reader.ReadLine();
while (str != null)
{
//Response.Write(str);
//str = reader.ReadLine();

history();
lblStatus.Text = "Message Sent";
}
history();
}

private void history()
{


try
{
if (con.State.ToString() == "Closed")
con.Open();
com = new SqlCommand();
com.Connection = con;
com.CommandText = "Insert Into msgtable (msg,userid,mobileno,date) values(@msg,@userid,@mobileno,@date)";

SqlParameter msg1 = new SqlParameter("@msg", SqlDbType.VarChar,50);
msg1.Value = txtmessage.Text;
com.Parameters.Add(msg1);

SqlParameter userid = new SqlParameter("@userid",SqlDbType.VarChar,50);
userid.Value = Session["user"].ToString();
com.Parameters.Add(userid);

SqlParameter mobileno = new SqlParameter("@mobileno",SqlDbType.VarChar,50);
mobileno.Value = txtno.Text;
com.Parameters.Add(mobileno);

SqlParameter dt = new SqlParameter("@date",SqlDbType.VarChar,50);
DateTime dts = DateTime.Now;
dt.Value = dts.ToShortDateString();
com.Parameters.Add(dt);





com.ExecuteReader();
con.Close();
}
catch (Exception ex)
{
lblStatus.Text = ex.Message.ToString() + ex.Source + ex.HelpLink;
}
}



I am getting the following error afterwards:

error 101 net err_connection_reset unknown error
unable to load sms.aspx the site might be temporarly down.


please note that the above mentioned code is written in the codde behind file of sms.aspx file. on button click the it sends an sms to the given mobile number..
It does send the message but lateron i get this error instead of reloading the page..
 
Old June 5th, 2011, 05:01 PM
Wrox Author
 
Join Date: Sep 2010
Posts: 175
Thanks: 3
Thanked 53 Times in 53 Posts
Default

You should set breakpoints and use the debugger, then you should get better error messages. I guess the code your'e showing is in the file sms.aspx that is also shown in the error. With the database access, you are defining an INSERT statement. However, with the command object you invoke the method ExecuteReader. ExecuteReader should return a number of rows which is not done by the INSERT statement. For calling the INSERT statement you should invoke the method ExecuteNonQuery instead.
__________________
Christian
CN innovation
Visit my blog at: csharp.christiannagel.com
Follow me on twitter: @christiannagel





Similar Threads
Thread Thread Starter Forum Replies Last Post
Page 101 Kim_arg_js BOOK: Beginning JavaScript 4th Edition 0 July 6th, 2010 02:04 PM
Error in Migrating Project from ASP to ASP.NET hbansal ASP.NET 1.0 and 1.1 Professional 0 September 12th, 2008 05:48 AM
Total newbie to JSCRIPT-101 question rgouette Other Programming Languages 3 October 15th, 2007 12:28 PM
Chapter 3, page 101. File modes. venquessa BOOK Beginning Linux Programming, 3rd Edition 2 December 3rd, 2004 01:30 AM
ASP.NET Using VB.NET Chapt 3 Code error? uh6uj All Other Wrox Books 1 February 26th, 2004 10:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.