Ошибка компиляции Get data()
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data; using System.Text; public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownList1.DataSource = GetData(); DropDownList1.DataValueField = "Branch"; DropDownList1.DataTextField = "Branch"; DropDownList1.DataBind(); } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { using (SqlConnection Cn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\AAAAAAAAAAA\FINGERPRINT\APP_DATA\QUESTIONS.MDF;Integrated Security=True;")) { using (SqlCommand Cmd = new SqlCommand("select * from questions where Branch= @Branch")) { Cn.Open(); Cmd.Parameters.AddWithValue("@Branch", int.Parse(DropDownList1.SelectedValue)); SqlDataReader Dr = Cmd.ExecuteReader(); if (Dr.HasRows) { GridView1.DataSource = Dr; GridView1.DataBind(); } Dr.Close(); Cn.Close(); } } } DataTable GetData() { DataTable dt = new DataTable(); SqlConnection Con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\AAAAAAAAAAA\FINGERPRINT\APP_DATA\QUESTIONS.MDF;Integrated Security=True;"); { SqlCommand Cmd = new SqlCommand("SELECT * FROM questions "); Con.Open(); SqlDataAdapter adpt = new SqlDataAdapter(Cmd); adpt.Fill(dt); } } }
Что я уже пробовал:
я попробовал добавить protected но получил ту же ошибку в таблице данных getdata()
Tomas Takac
Какая ошибка?