Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 3rd, 2011, 04:07 AM
Authorized User
Points: 112, Level: 2
Points: 112, Level: 2 Points: 112, Level: 2 Points: 112, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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..
Reply With Quote
  #2 (permalink)  
Old June 5th, 2011, 05:01 PM
Wrox Author
Points: 1,038, Level: 12
Points: 1,038, Level: 12 Points: 1,038, Level: 12 Points: 1,038, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2010
Location: Austria
Posts: 142
Thanks: 0
Thanked 51 Times in 51 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: weblogs.thinktecture.com/cnagel
Follow me on twitter: @christiannagel
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 12:30 AM
ASP.NET Using VB.NET Chapt 3 Code error? uh6uj All Other Wrox Books 1 February 26th, 2004 09:46 AM



All times are GMT -4. The time now is 03:49 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.