15,949,741 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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 '='.