Welcome to Discuss Everything Forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.


 

Tags for this Thread

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Saed G's Avatar
    Junior Member

    Status
    Offline
    Join Date
    May 2009
    Posts
    5
    Downloads
    0
    Uploads
    0

    how to connect Sql database in ASP.NET?

    im new to ASP.NET and i made a table and put some data in it to test it ... and i made a text box and a button , i want to search the database and retrieve the information in a grid view !!

    here's my code

    SqlConnection q1 = new SqlConnection(SqlDataSource1.ConnectionString);
    SqlCommand cmd1 = new SqlCommand("SELECT * FROM [Drs] WHERE ([Name] = @Name) ", q1);

    cmd1.Parameters.AddWithValue("@Name", TextBox1.Text);

    q1.Open();
    SqlDataReader dr = cmd1.ExecuteReader();

    /// of course i put the Using System.Data.Sqlclient ;

    but there's nothing appears in the grid view

    im using VS2010

  2. #2
    Throw a try catch block on this line
    SqlDataReader dr = cmd1.ExecuteReader();
    and a break point and step throguh and see if it is throwing an error and you can see what that error is.

 

 

Quick Reply Quick Reply

Click here to log in


What is the number after 87?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 10-26-2011, 03:43 AM
  2. Replies: 0
    Last Post: 12-13-2010, 04:08 AM
  3. Replies: 0
    Last Post: 12-04-2009, 11:05 PM
  4. Replies: 1
    Last Post: 12-22-2008, 11:37 PM
  5. Replies: 0
    Last Post: 12-18-2008, 03:15 PM

Bookmarks

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •