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