TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Narasiman nar
NA
64
22.5k
fill selectcommand.connection property has not beeninitializ
Jun 8 2018 1:15 AM
fill selectcommand.connection property has not been initialized
if
(e.CommandName ==
"UploadFarmData"
)
{
string
CurrentFilePath = Path.GetFullPath(FileUpload1.PostedFile.FileName);
constr =
string
.Format(@
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties="
"Excel 12.0 Xml;HDR=YES;"
""
, CurrentFilePath);
Econ =
new
OleDbConnection(constr);
Econ.Open();
DataTable dtExcelSchema;
dtExcelSchema = Econ.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
null
);
string
sheetName = dtExcelSchema.Rows[0][
"TABLE_NAME"
].ToString();
DataSet ds =
new
DataSet();
string
SheetName = dtExcelSchema.Rows[0][
"TABLE_NAME"
].ToString();
OleDbCommand cmdExcel =
new
OleDbCommand();
OleDbDataAdapter da =
new
OleDbDataAdapter();
cmdExcel.CommandText =
"SELECT * From ["
+ SheetName +
"]"
;
da.SelectCommand = cmdExcel;
da.Fill(ds);
Econ.Close();
DataTable dt =
new
DataTable();
dt = ds.Tables[0];
bool
s =
false
;
if
(dt.Rows.Count > 0)
{
for
(
int
i = 0; i < dt.Rows.Count; i++)
{
dal.DAL_Insert_Farm_Data(dt.Rows[i][
"Farmer Code"
].ToString(), dt.Rows[i][
"Farm No"
].ToString(),
dt.Rows[i][
"Type of Farm"
].ToString(), dt.Rows[i][
"Seeded Date"
].ToString(), dt.Rows[i][
"Farm Visit No"
].ToString());
s =
true
;
}
if
(s)
{
showStatusTrue.InnerHtml =
"Farm Details Uploaded Successfully"
;
dal.DAL_Data_Update();
}
when run the above shows error as follows
fill selectcommand.connection property has not been initialized
how to fix this error. please let me know.
Reply
Answers (
1
)
Serial port data into RIng Buffer
How to load MS Excel VBA Macros in Web Application