SqlServer的Image类型与Oracle的Blob互相写入的问题
SqlServer中S表有个字段是Image类型,用于存放Mail附件的
Oracle中O表也有个字段Blob类型,也是存放Mail附件的
我要把一些sqlserver中的附件数据导入到oracle中,同时也有一些Oracle中的附件导入到sqlserver中。
但是无论是把sqlserver的数据写入oracle,还是把oracle的blob数据写入sqlserver,都会出错。
哪位高手帮帮忙看一下,感激不尽了...
如果可以的话小弟可以把剩下来的代码都发过去方便大大们诊断..
其中邮件操作的那一段代码如下:
private void TransferMailing()
{
string maildomain = textBoxMailDomain.Text;
string oaSql = "select * from rx_oa_mailing where Instr(MailTo, ' " + maildomain + " ') <1 ";
DataSet ds = SqlHelper.ExecuteReader(this.OAConnction.ConnectionString, this.OAConnction.ProviderName, oaSql);
if (ds.Tables.Count > 0)
{
DataTable dt = ds.Tables[0];
foreach (DataRow dr in dt.Rows)
{
string mailId = dr[ "mail_Id "].ToString().Trim();
string mailTo = dr[ "mailto "].ToString().Trim();
string mailFrom = dr[ "mailer_addr "].ToString().Trim();
string fromName = dr[ "mailer_name "].ToString().Trim();
string copyTo = dr[ "copyTo "].ToString().Trim();
string privateTo = dr[ "privateTo "].ToString().Trim();
string subject = dr[ "subjet "].ToString().Trim();
string content = dr[ "content "].ToString().Trim().Replace( " ' ", " ");
string attachSum = dr[ "attachsum "].ToString().Trim();
if (mailTo.IndexOf( "@ " + maildomain) < 0)
{
string mailSql = "insert into OA_MAIL(MAILFROM,FROM_NAME,MAILTO,CCLIST,BCCLIST,SUBJECT,CONTENT,ATTACH_COUNT) ";
mailSql += " values( ' " + mailFrom + " ', ' " + fromName + " ', ' " + mailTo + " ', ' " + copyTo + " ', ' " + privateTo + " ', ' " + subject + " ', ' " + content + " ', " + attachSum + ") select @@identity ";
labelMailing.Text = "当前发送邮件至 " + mailTo;
DataSet mailds = new DataSet();
//Send Mailing Attach
try
{
mailds = SqlHelper.ExecuteReader(this.MailConnction.ConnectionString, this.MailConnction.ProviderName, mailSql);
}
catch (Exception ce)
{
logger.Error( "OA to Mail Body: " + ce.Message);
}
if (mailds.Tables.Count > 0)
{
string newMailId = mailds.Tables[0].Rows[0][0].ToString().Trim();
//insert mailing Attach
string oaAttachSql = "select * from RX_OA_Mailing_Attach where Mail_Id= " + mailId;
DataSet ads = SqlHelper.ExecuteReader(this.OAConnction.ConnectionString, this.OAConnction.ProviderName, oaAttachSql);
if (ads.Tables.Count > 0)
{
DataTable adt = ads.Tables[0];
foreach (DataRow adr in adt.Rows)
{
string filename = adr[ "FileName "].ToString().Trim();
byte[] filecontent = (Byte[])adr[ "Content "];
string mailAttachSql = "insert into OA_Attach(ID_NUM,FILENAME,CONTENT) values(@mailid,@filename,@filecontent) ";
Hashtable ht = new Hashtable();
ht.Add( "mailid ", newMailId);
ht.Add( "filename ", filename);
ht.Add( "filecontent ", filecontent);
try
{
SqlHelper.ExecuteQueryByParam(this.MailConnction.ConnectionString, this.MailConnction.ProviderName, mailAttachSql, ht);
}
catch(Exception ce)
{
logger.Error( "OA to Mail Attach: " + ce.Message);
}
}
}
//Delete mailing
string deleteMailSql = "delete from rx_oa_mailing where mail_Id= " + mailId;
SqlHelper.ExecuteNonQuery(this.OAConnction.ConnectionString, this.OAConnction.ProviderName, deleteMailSql);
}
labelMailing.Text = "发送邮件至 " + mailTo + "完成 ";
}
else
{
string deleteMailSql = "delete from rx_oa_mailing where mail_Id= " + mailId;
SqlHelper.ExecuteNonQuery(this.OAConnction.ConnectionString, this.OAConnction.ProviderName, deleteMailSql);
}
}
}
}
[解决办法]
友情帮助
[解决办法]
mark...