DataTable의 데이터의 첫 번째 열을 텍스트 상자에 채우고 싶습니다.DataTable의 데이터로 텍스트 상자를 채우는 방법
구문을 어떻게 할 것입니까?
나는 지금까지 이것을 가지고 있었지만 마지막 줄에 오류가 발생했다.
DataTable dt = new DataTable();
string strConnection = ConfigurationManager.ConnectionStrings["ChinatowndbConnString"].ConnectionString;
SqlConnection conn = new SqlConnection(strConnection);
string sql = "SELECT * FROM vwSchedule where scheduleid =" + scheduleid;
SqlCommand cmd = new SqlCommand(sql);
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
SqlDataAdapter sd = new SqlDataAdapter(cmd);
sd.Fill(dt);
tbEvent.Text dt.Rows[0].Field<String>(0); // first field of first row, assuming that it's a string
감사 차 당신은 마지막 줄 구문에서 같음이 누락
그래서 작동하지 않습니다. tbEvent.Text dt.Rows [0] .Field (0);을'tbEvent.Text = dt.Rows [0] .Field (0);으로 대체하면 예상대로 작동해야합니다. 행이고 첫 번째 열의 유형은 문자열). –
coulmn 0은 문자열이 아닐 수 있습니다. – AMember
실수로, = 기호를 잊어 버렸습니다. – TeaDrinkingGeek