-
27-03-2011, 06:10 PM #1Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
lỗi Error The type or namespace name 'DbDataReader' could not be found (are you missing
chào các bạn.mình có viết một trang web page để import dữ liệu excel vào trong DB SQL server 2005.
Đây là code:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;//vao webstie, chon .net, them file system.core
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;//vào website, chọn .net tab, them System.Xml.Linq
using System.Data.SqlClient;
using System.Data.OleDb;
public partial class Quan_tri_QHKH_Man_hinh_QL_TTin_SDDV_importdl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnUpload_Click(object sender, EventArgs e)
{
string xConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("ExcelImport.xls") + ";" + "Extended Properties=Excel 8.0;";
using (OleDbConnection connection = new OleDbConnection(xConnStr))
{
OleDbCommand command = new OleDbCommand("Select * FROM [Sheet1$]", connection);
connection.Open();
// Create DbDataReader to Data Worksheetusing ()
DbDataReader dr = command.ExecuteReader();
{
// SQL Server Connection String
string sqlConnectionString = DataAcess.GetConnectionString();
// Bulk Copy to SQL Serverusing ()
SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString);
{
bulkCopy.DestinationTableName = "ConsumerGRY_CAL";
bulkCopy.WriteToServer(dr);
}
}
}
}
}
Nó báo lỗi như thế này: Error 1 The type or namespace name 'DbDataReader' could not be found (are you missing a using directive or an assembly reference?)
và lỗi:Error 2 The best overloaded method match for 'System.Data.SqlClient.SqlBulkCopy.WriteToServer(S ystem.Data.IDataReader)' has some invalid arguments
Error 3 Argument '1': cannot convert from 'DbDataReader' to 'System.Data.IDataReader'
Bạn nào biết cách sữa mấy cái lỗi này giúp mình vớiView more random threads:
- Cập nhật lại ảnh trong asp.net
- Xử lý Cookie trong ASP.NET như thế nào? Cookie được lưu ở đâu?
- Dùng 2 Famework hay Engine cùng lúc trong Lập trình Web được không ?
- Tạo menu đổ xuống khi rê chuột trong ASP.NET thì làm sao?
- Cách thay đổi tọa độ của textbox trong Asp.net+c#
- Làm sao up hình bằng ckeditor từ thư mục nằm ngoài thư mục chứa website?
- Tạo slideshow jquery mà các ảnh được lấy từ CSDL
- Cách sửa, xóa dữ liệu trong DataList giống DatagridView trên Winform?
- Làm thế nào để truyền dữ liệu từ winform sang webform thông qua webservice..?
- Xử lý ItemCommand của Repeater lồng nhau trong C#?
Thông qua phân tích dữ liệu Google từ 86 quốc gia, mới đây, một công ty tại Anh đã công bố bảng xếp hạng kích tấc "cậu nhỏ" của các nước trên thế giới. Kết quả, hầu hết các nước xếp ở nhóm đầu của...
"Chim" của chàng trai Việt thuộc...