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
Bharathi Raja
NA
1.1k
54.5k
External table is not in the expected format.
Apr 26 2018 12:16 AM
csv File Upload In mysql database in wamp server
how this error Clear..
External table is not in the expected format.
//choose path
private
void
button1_Click(
object
sender, EventArgs e)
{
OpenFileDialog dlg =
new
OpenFileDialog();
dlg.Filter =
"Text files | *.csv"
;
if
(dlg.ShowDialog() == DialogResult.OK)
{
string
fileName;
fileName = dlg.FileName;
txtFileName.Text = fileName;
}
}
//submit button
private
void
button2_Click(
object
sender, EventArgs e)
{
if
(txtFileName.Text !=
""
)
{
string
path = txtFileName.Text;
string
id =
""
;
string
pimage =
""
;
string
cate =
""
;
string
subcat =
""
;
string
pcode =
""
;
string
peng =
""
;
string
ptam =
""
;
string
barcode =
""
;
string
unit =
""
;
string
promrp =
""
;
string
procast =
""
;
string
pprice =
""
;
string
aqty =
""
;
string
alertqty =
""
;
string
pdetail =
""
;
string
tax =
""
;
string
mdate =
""
;
string
edate =
""
;
OleDbConnection my_con =
new
OleDbConnection(
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
+ path +
";Extended Properties=Excel 12.0;"
);
my_con.Open();
External table is not in the expected format.//this line error throw
OleDbCommand icmd =
new
OleDbCommand(
"SELECT * FROM [dataGridView1_Data$]"
, my_con);
OleDbDataReader dr = icmd.ExecuteReader();
while
(dr.Read())
{
id = dr[0].ToString();
pimage = dr[1].ToString();
cate = dr[2].ToString();
subcat = dr[3].ToString();
pcode = dr[4].ToString();
peng = dr[5].ToString();
ptam = dr[6].ToString();
barcode = dr[7].ToString();
unit = dr[8].ToString();
promrp = dr[9].ToString();
procast = dr[10].ToString();
pprice = dr[11].ToString();
aqty = dr[12].ToString();
alertqty = dr[13].ToString();
pdetail = dr[14].ToString();
tax = dr[15].ToString();
mdate = dr[16].ToString();
edate = dr[17].ToString();
MySqlConnection con =
new
MySqlConnection(
"SERVER=localhost;"
+
"DATABASE=shop_management;"
+
"UID=root;"
+
"PASSWORD=;"
);
con.Open();
MySqlCommand icmmd =
new
MySqlCommand(
"INSERT INTO add_product(id,product_image,category,sub_category,product_code,product_english, product_tamil, barcode,unit,product_mrp,product_cost,product_price,available_quantity,alert_quantity,product_detail,tax,man_date,exp_date)VALUES(@a,@b,@c,@d,@e,@f,@g,@h,@i,@j,@k,@l,@m,@n,@o,@p,@q,@r)"
, con);
icmmd.Parameters.AddWithValue(
"a"
, id);
icmmd.Parameters.AddWithValue(
"b"
, pimage);
icmmd.Parameters.AddWithValue(
"c"
, cate);
icmmd.Parameters.AddWithValue(
"d"
, subcat);
icmmd.Parameters.AddWithValue(
"e"
, pcode);
icmmd.Parameters.AddWithValue(
"f"
, peng);
icmmd.Parameters.AddWithValue(
"g"
, ptam);
icmmd.Parameters.AddWithValue(
"h"
, barcode);
icmmd.Parameters.AddWithValue(
"i"
, unit);
icmmd.Parameters.AddWithValue(
"j"
, promrp);
icmmd.Parameters.AddWithValue(
"k"
, procast);
icmmd.Parameters.AddWithValue(
"l"
, pprice);
icmmd.Parameters.AddWithValue(
"m"
, aqty);
icmmd.Parameters.AddWithValue(
"n"
, alertqty);
icmmd.Parameters.AddWithValue(
"o"
, pdetail);
icmmd.Parameters.AddWithValue(
"p"
, tax);
icmmd.Parameters.AddWithValue(
"q"
, mdate);
icmmd.Parameters.AddWithValue(
"r"
, edate);
icmmd.ExecuteNonQuery();
con.Close();
}
MessageBox.Show(
"data Imported"
);
txtFileName.Text =
""
;
}
else
if
(txtFileName.Text ==
""
)
{
}
}
}
Reply
Answers (
1
)
DataGridView RowValidating e.Cancel locks user input.
I can Change My Computer Date.Now how can i get today date