在此代码中,我必须将Sqlite数据插入SQL server.First,我必须将所有数据都存储在sqlite数据库中,然后单击按钮整个数据应插入SQL server.My中。问题是在所有rows.For示例中唯一插入的第一行;如果我在sqlite中插入了三个不同的行,但这三行在Sql server中具有相同的第一行值...如何解决。我正在使用Move to first和Move to next also...but,我无法获取。伙计们,我需要你们的帮助
//数据库编码
public class Database extends SQLiteOpenHelper {
static int dbversion=1;
static String dbname="auction.db";
String TABLE_CONTACTS = "auctions";
public Database(Context context)
{
super(context, dbname, null, dbversion);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table Auction(boname VARCHAR NOT NULL,bname VARCHAR NOT NULL, amount VARCHAR NOT NULL,daty DATE)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
}
}// JAva编码
public void onClick(View v) {
// TODO Auto-generated method stub
Database db=new Database(MainActivity.this);
SQLiteDatabase sb=db.getReadableDatabase();
Cursor cus=sb.rawQuery("select * from Auction",null);
cus.moveToFirst();
for(int i=0;i<cus.getCount();i++)
{
String Boatnum= cus.getString(0).toString();
String Buyername=cus.getString(1).toString();
String amount= cus.getString(2).toString();
request.addProperty("Boatnum",Boatnum);
request.addProperty("Buyername",Buyername);
request.addProperty("amount",amount);
envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
httpTransport = new HttpTransportSE(SOAP_ADDRESS);
try {
serviceCall();
}
catch (Exception exception) {
//Toast.makeText(getActivity(), "Registered Successfully", Toast.LENGTH_LONG).show();
}
cus.moveToNext();
}
}发布于 2015-03-16 17:05:25
您是否可以注释您当前的代码,并尝试以下代码:
Cursor cus=sb.rawQuery("select * from Auction",null);
if (cus != null) {
cus.moveToFirst();
}注释每一件事,并且只在你的方法中有这些,并尝试让我知道发生了什么。
https://stackoverflow.com/questions/29071297
复制相似问题