Skip to content

Ozar.net Developer Blog

Programming in PHP, C, C#, ASP.NET, Java, Objective-C, SQL also for MS SQL Server, Oracle & MySQL Development

Menu
  • Home
  • About
  • Tutorials
  • Contact
  • Privacy
Menu

Asp.Net ?

Posted on March 30, 2010March 30, 2010 by OD

well i want retrieve data from sql to my . net page.. i have a set a combo box.. where all user name have to be stored . one selecting any name all other values should be displayed.. i wrote this coding but i get error.
SqlConnection con = new SqlConnection(“Data Source=ORG-99DBE221248;Initial Catalog=pubs;Integrated Security=True”);
String sName = “select * from feedback where uname='” + cuname.Text + “‘”;

email.Text = email ;
sites.Text = site ;
pro.Text= pro ;
cm.Text = cm ;
qa.Text = aq;
sug.Text = Sug ;
Qlike.Text = Qlike ;
dislike.Text = dislike ;
SqlCommand cmd = new SqlCommand(sName,con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
Error are shown where i assign text box and sql value… can anybody rectify this error plz. i use c# language

2 thoughts on “Asp.Net ?”

  1. ProZer says:
    March 30, 2010 at 11:18 AM

    Try this code. And dont use String concat operations.
    using( SqlConnection connection = new SqlConnection(“Data Source=ORG-99DBE221248;Initial Catalog=pubs;Integrated Security=True”) )
    {
    SqlCommand command = new SqlCommand(“SELECT * FROM feedback WHERE ( UNAME = @UNAME )”);
    command.Parameters.Add(“@UNAME”, SqlDbTypes.Text) = cuname.Text;

    SqlDataReader reader = null;
    try
    {
    connection.Open();
    reader = command.ExecuteReader();
    if ( reader.HasRows )
    {
    while ( reader.Read() )
    {
    email.Text = reader.GetString( database table field index like 0 );
    if email columns first column in the table then you must use 0 for first column
    email.Text = reader.GetString(0);
    sites.Text = reader.GetString(1);
    }

    reader.Close();
    }
    connection.Close();
    reader.Dispose();
    } catch ( SqlException ex )
    {
    // Handle errors
    } // End Try
    } / / End U”sing

    Log in to Reply
  2. nutwpinut says:
    March 30, 2010 at 12:00 PM

    Looking at this code it seems you are assigning email.Text = email etc.. before you run the actual query.

    Are you sure you are getting a result back from your query? Print out the query and run it from the database to make sure the query actually returns a result.

    Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Recent Posts

  • NSTableView with Core Data Tutorial using NSFetchedResultsController
  • CodeIgniter Wizard – a new PHP CRUD Code Generator for macOS
  • Installing Oracle Database 10g Express Edition and Changing the Default HTTP Port
  • Xcode Tutorial 2 – Putting iAd into your App (The Apple Approved Way)
  • Cocoa Programming: A Quick-Start Guide for Developers

Blogroll

  • All Systems GO
  • GOZmosis
  • Maclord's Blog
  • Ozar.net

Tags

.NET 2008 application ASP.NET basic Beginning best books business Business Objects C# Database Databases Development Edition Guide iPhone Java Java EE learn Learning Microsoft MS SQL Server MySQL Objective-C Programming objects Oracle Part PHP PL/SQL Professional Programming Server Software SQL T-SQL TSQL Tutorial Tutorials Using Video Visual Visual Basic .NET Web Programming Tutorials XCode
© 2026 Ozar.net Developer Blog | Powered by Minimalist Blog WordPress Theme

Powered by
►
Necessary cookies enable essential site features like secure log-ins and consent preference adjustments. They do not store personal data.
None
►
Functional cookies support features like content sharing on social media, collecting feedback, and enabling third-party tools.
None
►
Analytical cookies track visitor interactions, providing insights on metrics like visitor count, bounce rate, and traffic sources.
None
►
Advertisement cookies deliver personalized ads based on your previous visits and analyze the effectiveness of ad campaigns.
None
►
Unclassified cookies are cookies that we are in the process of classifying, together with the providers of individual cookies.
None
Powered by