我有一个Response.Redirect在我的Page_Load:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
...Code
Response.Redirect("http://www.mysite.com")
End Sub
Run Code Online (Sandbox Code Playgroud)
在添加Response.Redirect之前,我有其他子例程和工作代码
当Response.Redirect加入他们都不会处理自己的代码,并自动执行该Response.Redirect网站.
当没有时,我的代码可以正常工作Response.Redirect.
我有Excel 2007和Visual Web Developer Express 2010.我想导入xlsx文件的Sheet1然后将数据添加到数据集并将该数据放入MS SQL数据库.
string ExcelConStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES";
string SQLConStr = "got connection string that works";
OleDbConnection ExcelConnection = new OleDbConnection(ExcelConStr);
using (ExcelConnection)
{
string sql = string.Format("Select * FROM [{0}]", "Sheet1$");
OleDbCommand command = new OleDbCommand(sql, ExcelConnection);
ExcelConnection.Open();
using (OleDbDataReader dr = command.ExecuteReader())
{
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(SQLConStr))
{
bulkCopy.DestinationTableName = "dbo.databaseName";
bulkCopy.WriteToServer(dr);
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果有人可以提出建议,我需要像批量复制一样免费且易于使用的东西.