Question: One Error Left: Severity Code Description Project File Line Suppression State Error CS1729 'SqlDataReader' does not contain a constructor that takes 0 arguments AddressBook 34

One Error Left:

Severity

Code

Description

Project

File

Line

Suppression State

Error

CS1729

'SqlDataReader' does not contain a constructor that takes 0 arguments

AddressBook

34

Active

Default.aspx

using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;

namespace AddressBook { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {

}

private void rep_bind() { SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI"); //here you need mention your Datasource details string query = "select * from customer where Name like'" + TextBox1.Text + "%'";

SqlDataAdapter da = new SqlDataAdapter(query, con); DataSet ds = new DataSet(); da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); }

protected void Button1_Click(object sender, EventArgs e) { SqlDataReader dr = new SqlDataReader(); if (dr.HasRows) { dr.Read();

rep_bind(); GridView1.Visible = true;

TextBox1.Text = ""; Label1.Text = ""; } else { GridView1.Visible = false; Label1.Visible = true; Label1.Text = "The search Term " + TextBox1.Text + " Is Not Available in the Record"; } } } }

Label.cs

namespace AddressBook { internal class Label1 { internal static bool Visible; internal static string Text; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!