테이블에서 데이터를 검색하고 텍스트 상자 및 콤보 상자의 입력으로 피드를 공급하기 위해 SqlServer 데이터베이스 연결을 설정하고 있습니다.C# : Connection이 DataTable의 컨트롤 요소를 채우지 못함
아무 예외 나 오류 메시지가 나타나지 않지만 모든 데이터가 테이블에 저장되어 반환 되더라도 결과는 예상과 다를 수 있습니다. 두 개의 콤보 상자가 예상대로 작동하지 않습니다. 두 개의 컨트롤 뒤에있는 기어가 모두 패널에 자리 잡은 picturebox에 배치되어 있습니다! 당신은 키우면 텍스트 속성을 설정하여 콤보 상자를 채우기하지는
try
{
using (SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=SmartCity;Integrated Security=True"))
{
DataTable db = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter("SELECT card_type,card_n
umber,exp_month,exp_year,cvv FROM CreditCards WHERE user_id='" + ApplicationState.CurrentUser.userid.ToString() + "'", con);
sda.Fill(db);
//MessageBox Prints the missing data perfectly though!
MessageBox.Show("Cart Type:" + db.Rows[0][0].ToString()
+ "\nExpiration Month:" + db.Rows[0][2].ToString());
txtcardholername.Text = ApplicationState.CurrentUser.name + " " + ApplicationState.CurrentUser.surname;
cboxcardtype.Text = db.Rows[0][0].ToString();
txtcardnumber.Text = db.Rows[0][1].ToString();
cboxmonth.Text = db.Rows[0][2].ToString();
cboxexpyear.Text = db.Rows[0][3].ToString();
txtcvv.Text = db.Rows[0][4].ToString();
}
}
catch (Exception)
{
MessageBox.Show("Something went wrong!");
}
만 콤보 동안 기입하지 않습니다? – abdul
예 [2016,2017,2018 ....로 초기화 된 관리 년도가 완벽하게로드 중이었습니다! – HelloIT