TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
shahana poinen
NA
3
733
I am having NullReferenceException
May 24 2015 3:37 PM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
public partial class Currency : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string senderNum;
string receiverNumber;
string reg;
senderNum = Request.QueryString.Get("sender");
receiverNumber = Request.QueryString.Get("receiver");
reg = Request.QueryString.Get("msg");
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["rateD"].ConnectionString);
char[] splitchar = { ' ' };
if (reg == null == false)
{
string[] regis = reg.Split(splitchar);
string username;
string password;
//bool readerHasRows = false;
username = regis[0].ToString();
password = regis[1].ToString();
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT Username FROM tblreg WHERE Username = @Username", conn);
cmd.Parameters.AddWithValue("@username", username);
SqlDataAdapter da = new SqlDataAdapter(cmd);
System.Data.DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
//Try
Response.Redirect("http://localhost:9333/CurrencyConvertorOzeki?login=admin&password=abc123&action=sendMessage&messagetype=SMS:TEXT&recepient=" + senderNum + "&messageData= User already registered, Please register again");
}
else
{
SqlCommand cmd4 = new SqlCommand("INSERT INTO tblreg VALUES(@username,@password)", conn);
cmd4.Parameters.AddWithValue("@username", username);
cmd4.Parameters.AddWithValue("@password", password);
cmd4.ExecuteNonQuery();
Response.Redirect("http://localhost:9333/CurrencyConvertorOzeki?login=admin&password=abc123&action=sendMessage&messagetype=SMS:TEXT&recepient=" + senderNum + "&messageData= user succesfully registered");
}
}
else
{
string[] con = reg.Split(splitchar);
string username;
double value;
string count1;
string count2;
username = con[0].ToString();
value = double.Parse(con[1]);
count1 = con[2].ToString();
count2 = con[3].ToString();
conn.Open();
SqlCommand cmd5 = new SqlCommand("SELECT Username FROM tblreg WHERE Username = @Username", conn);
cmd5.Parameters.AddWithValue("@username", username);
SqlDataAdapter da1 = new SqlDataAdapter(cmd5);
System.Data.DataTable dt1 = new DataTable();
da1.Fill(dt1);
if (dt1.Rows.Count > 0)
{
conn.Open();
SqlCommand cmd6 = new SqlCommand("SELECT CountryCode FROM tblCountry WHERE CountryCode = @CountryCode1 AND CountryCode= @CountryCode2", conn);
cmd6.Parameters.AddWithValue("@CountryCode1", count1);
cmd6.Parameters.AddWithValue("@CountryCode2", count2);
SqlDataAdapter dac = new SqlDataAdapter(cmd6);
System.Data.DataTable dtc = new DataTable();
dac.Fill(dtc);
if (dtc.Rows.Count > 0)
{
net.webservicex.www.CurrencyConvertor conver = new net.webservicex.www.CurrencyConvertor();
net.webservicex.www.Currency From = (net.webservicex.www.Currency)Enum.Parse(typeof(net.webservicex.www.Currency), count1.ToString(), true);
net.webservicex.www.Currency To = (net.webservicex.www.Currency)Enum.Parse(typeof(net.webservicex.www.Currency), count2.ToString(), true);
double d = conver.ConversionRate(From, To);// web service method to call for conversion currency rate
String message = count1 + " To " + count2 + " : " + (d * Convert.ToDouble(value)).ToString();
Response.Redirect("http://localhost:9333/CurrencyConvertorOzeki?login=admin&password=abc123&action=sendMessage&messagetype=SMS:TEXT&recepient=" + senderNum + "&messageData=" + message + "");
}
}
else
{
Response.Redirect("http://localhost:9333/CurrencyConvertorOzeki?login=admin&password=abc123&action=sendMessage&messagetype=SMS:TEXT&recepient=" + senderNum + "&messageData= Please first register to get access to the service");
}
}
}
}
Reply
Answers (
6
)
The webpage is unavailable because of working on offline.
About data base