Click here to Skip to main content
15,877,168 members

Comments by Coder-Ferg (Top 4 by date)

Coder-Ferg 23-Apr-14 14:03pm View    
The column type is varchar(7)
Coder-Ferg 23-Apr-14 6:05am View    
Sorry, both of the above were the methods that were not working. Here is the one that works .

protected void perInfoDDL_SelectedIndexChanged1(object sender, EventArgs e)
{
//Creating Select statement that searches for record that matches PersonalID from Value property.
string perInfoSelectSql;
perInfoSelectSql = "SELECT * FROM Personal"; // maybe "SELECT PersonalUsername, Surname, FirstName, PersonalEmail, TelephoneNo FROM Personal"; "SELECT * FROM Personal";
perInfoSelectSql += " WHERE PersonalID= '" + perInfoDDL.SelectedItem.Value + "'";

//Defining the ADO.NET objects
SqlConnection conA1 = new SqlConnection(adminCon);
SqlCommand cmdA1 = new SqlCommand(perInfoSelectSql, conA1);
SqlDataReader readerA1;

//Opening database & reading information
try
{
conA1.Open();
readerA1 = cmdA1.ExecuteReader();
readerA1.Read();

//building a string with the record information and displaying in label.

StringBuilder perInfoSB = new StringBuilder(); //use System.Text with it
perInfoSB.Append("");
perInfoSB.Append("Username:");
perInfoSB.Append(readerA1["UserName"]);
perInfoSB.Append("
<br/>");
perInfoSB.Append("<br/>");
perInfoSB.Append("PersonalID:");
perInfoSB.Append(readerA1["PersonalID"]);
perInfoSB.Append("<br/>");
perInfoSB.Append("Name:");
perInfoSB.Append(readerA1["Surname"]);
perInfoSB.Append(", ");
perInfoSB.Append(readerA1["FirstName"]);
perInfoSB.Append("<br/>");
perInfoSB.Append("Email:");
perInfoSB.Append(readerA1["PersonalEmail"]);
perInfoSB.Append("<br/>");
perInfoSB.Append("Phone:");
perInfoSB.Append(readerA1["TelephoneNo"]);
perInfoSB.Append("<br/>");
perInfoLabel.Text = perInfoSB.ToString();

readerA1.Close();
}
catch (Exception err)
{
perInfoLabel.Text = "Error reading Personal.";
perInfoLabel.Text += err.Message;
}
finally
{
conA1.Close();
}
}
Coder-Ferg 23-Apr-14 6:03am View    
Perfect! Thank you, worked for me.
Coder-Ferg 23-Apr-14 6:02am View    
Thank you, i tried that to, but for some reason when i run it in web browser it is still returning this error .

Incorrect syntax near '='.