I’m posting the upper portion of code. No matter what I do the compiler says I’m missing a name space or I’m using a method like a class or its expecting ‘or =’. I’m totally new to C# programming.
The problem: Query checks if people are in your network. People with others in network, no error. People without others in their network, error. (I didnt even get to looping through the network query to populate the ‘friends’ section in the XML portion if friends are in their network)
Thanks is advance for the help
<%@ Page language="c#" %>
<script runat="server" language="C#">
protected void Page_Load(object sender, EventArgs e)
{
string xml;
try
{
xml = Auth(Request.Params["uid"].ToString());
}
catch (Exception ex)
{
xml = ex.Message;
}
if (!string.IsNullOrEmpty(xml))
{
Response.Clear();
Response.ExpiresAbsolute = DateTime.Now;
Response.AddHeader("Content-type", "text/xml");
Response.Write(xml);
}
if (!string.IsNullOrEmpty(xml) || Request.Params["uid"] != string.Empty)
{
Response.End();
}
}
protected virtual string Auth(string uid)
{
String xml;
if (!String.IsNullOrEmpty(Request["uid"]))
{
System.Data.DataTable dtTable = new System.Data.DataTable();
System.Data.DataTable memTable = new System.Data.DataTable();
System.Data.DataTable netTable = new System.Data.DataTable();
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);
conn.Open();
string query = "SELECT userid, username, city, state, country, birthday, img1, userLevelName, gendername, title FROM UserInfo INNER JOIN Gend ON UserInfo.gendID = Gend.gendID INNER JOIN UserLevel ON UserInfo.UserLevelID = UserLevel.UserLevelID WHERE userid='" + Request["uid"] + "'";
System.Data.SqlClient.SqlDataAdapter adp = new System.Data.SqlClient.SqlDataAdapter(query, conn);
adp.Fill(dtTable);
//start of problem is that the next query checks to see if someone is in your network, people with others in network, no error. people without others in their network error
string query1 = "SELECT MemID FROM network WHERE userid='" + Request["uid"] + "'";
System.Data.SqlClient.SqlDataAdapter memdp = new System.Data.SqlClient.SqlDataAdapter(query1, conn);
memdp.Fill(memTable);
string query2 = "SELECT Distinct userid, username, img1, birthday, gendid, city, state, country, title FROM UserInfo WHERE (userinfo.userid IN (" + memTable.Rows[0]["memid"] + ")) AND userinfo.img1 is not null order by userinfo.username";
System.Data.SqlClient.SqlDataAdapter netdp = new System.Data.SqlClient.SqlDataAdapter(query2, conn);
netdp.Fill(netTable);
//end of problem
conn.Close();
xml = string.Format("<login result=\"OK\">" +
"<userData>" +
"<id><![CDATA[" + dtTable.Rows[0]["userid"] + "]]></id>" +
"<name><![CDATA[" + dtTable.Rows[0]["username"] + "]]></name>" +
"<gender><![CDATA[" + dtTable.Rows[0]["gendername"] + "]]></gender>" +
"<location><![CDATA[" + dtTable.Rows[0]["city"] + "]]>, <![CDATA[" + dtTable.Rows[0]["state"] + "]]>, <![CDATA[" + dtTable.Rows[0]["country"] + "]]></location>" +
"<age>22</age>" +
"<photo>http://www.somesite.com/thumbnail.asp?path=" + dtTable.Rows[0]["img1"] + "</photo>" +
"<thumbnail>http://www.somesite.com/thumbnail.asp?path=" + dtTable.Rows[0]["img1"] + "</thumbnail>" +
"<details><![CDATA[" + dtTable.Rows[0]["title"] + "]]></details>" +
"<level><![CDATA[" + dtTable.Rows[0]["userlevelname"] + "]]></level>" +
"<profileUrl>http://www.somesite.com/" + dtTable.Rows[0]["username"] + "</profileUrl>" +
"</userData>" +
"<friends>" +
"<friend>" +
"<id>2</id>" +
"<name>Bill</name>" +
"<gender>0</gender>" +
"<location>London, UK</location>" +
"<age>22</age>" +
"<photo>http://yourdomain/photos/bill.png</photo>" +
"<thumbnail>http://yourdomain/photos/bill_small.png</thumbnail>" +
"<details>Hello, I am Bill</details>" +
"<level>regular</level>" +
"</friend>" +
"</friends>" +
Try this.
P.S: Please do not code like what is given in your snippet.
Functionsare there for a reason. Also there is something calledStringBuilder. Whats the point on usingvirtualon aspx? This code just solves the errors. I am sad that you are not making a serious attempt at coding.