2
對於android.the而言,這是一種新的東西,我編寫了一個vb代碼來將一些數據上傳到SQL服務器,包括一個image.so我想創建一個android應用程序來查看這些數據通過創建一個下拉列表與數據庫中的主要條目..因此,無論何時我從下拉列表中選擇一些東西,它假設顯示其餘的列..反駁我的英語,但我希望你們有想法。連接並創建一個android應用程序以從MSSQL中檢索數據
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void query2() {
Log.i("Android"," MySQL Connect Example.");
Connection conn = null;
try {
String driver = "net.sourceforge.jtds.jdbc.Driver";
Class.forName(driver).newInstance();
//test = com.microsoft.sqlserver.jdbc.SQLServerDriver.class;
String connString = "jdbc:jtds:sqlserver:// AMD/SQLEXPRESS :1433/***********;encrypt=fasle;user=*******;password=*********;instance=SQLEXPRESS;";
String username = "Shawtari";
String password = "";
conn = DriverManager.getConnection(connString,username,password);
Log.w("Connection","open");
Statement stmt = conn.createStatement();
ResultSet forest = stmt.executeQuery("select * from aspnet_Users");
//Print the data to the console
while(forest.next()){
Log.w("username",forest.getString(3));
}
conn.close();
} catch (Exception e) {
Log.w("Error connection","" + e.getMessage());
}
}
}
好吧生病了試試讓你知道..謝謝 – Shawtari