从数据库读取数据并写入xml文件,从xml文件读取并写入数据库 [英] read data from database and write to xml file , read from xml file and write to database
问题描述
亲爱的朋友,
我使用以下代码(带有XML)在asp.net和sql服务器中备份和还原:
-------------------------------------------------- --------------------
Dear Friends,
I Backup and restore in asp.net and sql server using following code (with XML):
----------------------------------------------------------------------
public string RestoreData_to_Database(string tableName, DataSet XmlFileDS)
{
try
{
DataTable dt = new DataTable();
dt = XmlFileDS.Tables[0];
SqlBulkCopy bulkcopy = new SqlBulkCopy(connect.ConnectionString, SqlBulkCopyOptions.KeepIdentity );
bulkcopy.DestinationTableName = tableName;
bulkcopy.WriteToServer(dt);
return "true";
}
catch(Exception ex)
{
return ex.Message;
}
finally
{
CloseConnection();
}
}
-------------------------------------------------- ------
备份和还原在localhost上可以,但是在具有plesk控制面板的主机上,备份可以,但是在还原过程中会出现以下错误:
用户"a"登录失败.
--------------------------------------------------------
Backup and Restore is OK on localhost, but on a host with plesk control panel,Backup is OK but during restore following error occur :
Login failed for user ''a''.
in advance, Thanks a lot.
推荐答案
检查与数据库的连接字符串.
在托管环境中,您将必须使用获得的凭据.
Check your connection string to your database.
In a hosted environment you will have to use the credentials you were given.
这篇关于从数据库读取数据并写入xml文件,从xml文件读取并写入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!