0
저는 Android가 처음이에요. SQL Server에 이미 연결되어 있으며 데이터베이스에서 데이터를 검색하여 테이블에 표시하려고합니다.SQL Server 데이터베이스에서 데이터를 검색하는 방법은 무엇입니까?
public void QuerySQL(String COMANDOSQL) {
try {
//String sql="select * from Activity";
Statement stmt = ma.connect.createStatement();
stmt.executeQuery("SELECT * FROM "+excbtn.getText().toString()+"");
ResultSet rs=stmt.getResultSet();
ResultSetMetaData rsmd= rs.getMetaData();
int colcount=rsmd.getColumnCount();
int j=0;
while(rs.next()){
j++;
for(int i=1; i<=colcount; i++)
{
String ss=rsmd.getColumnName(i);
// create a new TextView
if(j<=colcount){
t = new TextView(this);
t.setText(ss);
t.setWidth(200);//Set to any meaningful text
t.setBackgroundColor(Color.YELLOW);
tr.addView(t); //Attach TextView to its parent (row)
TableRow.LayoutParams params =
(TableRow.LayoutParams)t.getLayoutParams();
params.column= i; //place at ith columns.
params.span = 1; //span these many columns,
params.setMargins(2,2,2,2);
params.width = TableRow.LayoutParams.FILL_PARENT;
params.height = TableRow.LayoutParams.WRAP_CONTENT;
t.setPadding(2, 2, 2, 2);
t.setLayoutParams(params);
//colhead=true;
}
t1 = new TextView(this);
String tabval=rs.getString(ss);
t1.setText(rs.getString(ss));
t1.setWidth(200);//Set to any meaningful text
// t1.setBackgroundColor(Color.YELLOW);
tr1.addView(t1); //Attach TextView to its parent (row)
TableRow.LayoutParams params1 =
(TableRow.LayoutParams)t.getLayoutParams();
params1.column= i; //place at ith columns.
params1.span = j; //span these many columns,
params1.setMargins(2,2,2,2);
params1.width = TableRow.LayoutParams.FILL_PARENT;
params1.height = TableRow.LayoutParams.WRAP_CONTENT;
t1.setPadding(2, 2, 2, 2);
t1.setLayoutParams(params1);
//String from = {ss1};
}
가 어떻게 데이터를 바인딩하고 어디 테이블 행을 실행 : 여기
코드인가? 원격 서버 -에 데이터베이스를 가정하여
는 데이터가 장치에 로컬 원격 서버 또는에서이다 (지금, 당신은 당신의 UI 부분에 데이터 초점을하면, WebService에를 사용하여 서버에서 데이터를 검색하는 방법에 초점)? – dd619
원격 서버 사용 .. – ibu
** 원격 서버 사용 ** @ dd619 – ibu