android sqlite 导出sqlserver,SQLite导出数据到SQLServer
using System;public interface IImportData{bool ImportData();}public class sqlite2sqlServer : IImportData{public virtual bool ImportData(){// TODO: implementbool isSuccessful = true;dedestinationTableN
using System;
public interface IImportData
{
bool ImportData();
}
public class sqlite2sqlServer : IImportData
{
public virtual bool ImportData()
{
// TODO: implement
bool isSuccessful = true;
dedestinationTableName = Destination;
using (sqliteDataReader reader = sqliteHelper.ExecuteReader(sql_sqlite))
using (System.Data.sqlClient.sqlBulkCopy bulkCopy = new System.Data.sqlClient.sqlBulkCopy(PubConstant.ConnectionString))
{
{
bulkCopy.DestinationTableName = Destination;
try
{
bulkCopy.WriteToServer(reader);
}
catch (Exception ex)
{
isSuccessful = false;
throw new Exception(ex.Message);
}
}
}
return isSuccessful;
}
public virtual bool Hook()
{
// TODO: implement
Type t = typeof(T);
T dal = (T)Assembly.GetAssembly(t).CreateInstance(t.FullName);
//XPWY.DAL.QuestionFace dal = new DAL.QuestionFace();
MethodInfo methodInfo = dal.GetType().GetMethod("GetList",new Type[]{typeof(string)});
DataSet ds = methodInfo.Invoke(dal,new String[] { " BatchID=" + this.BatchID.ToString() }) as DataSet;
//GetList(" BatchID=" + this.BatchID.ToString());
if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
return true;
}
else
{
return false;
}
}
public virtual bool ImportDataFromsqliteTosqlServer()
{
// TODO: implement
if(Hook)
{
return ImportData();
}
return false;
}
public System.Int32 BatchID;
public System.String Destination;
public System.String sql_sqlite;
}
public class QuestionFace : sqlite2sqlServer
{
public QuestionFace(System.Int32 nBatchID)
{
this.BatchID = nBatchID;
this.Destination="QuetionFace";
this.sql_sqlite="select * from QuestionFace";
}
public sealed bool ImportDataFromsqliteTosqlServer()
{
// TODO: implement
return base.ImportDataFromsqliteTosqlServer();
}
}
更多推荐
所有评论(0)