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
Mehmet Yilmaz
NA
29
2.2k
Excell to Acces Data Transfer
Aug 23 2017 8:16 AM
I just want to get the lines with tax ID "78898989898" and I want the numbers to be transferred in "0.00" format
string
patchmdb;
OleDbConnection cnEMP =
new
OleDbConnection();
private
void
button1_Click(
object
sender, EventArgs e)
{
string
patchxls = Application.StartupPath +
"\\taxlist.xls"
;
DataTable dtEMP =
new
DataTable();
string
ConnectionString = @
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ patchxls +
"; Extended Properties='Excel 8.0;HDR=No;'"
;
using
(OleDbConnection cnEMP =
new
OleDbConnection(ConnectionString.ToString()))
{
cnEMP.Open();
using
(OleDbCommand cmdEMP =
new
OleDbCommand(
"SELECT * FROM [tax$C5:M]"
, cnEMP))
{
using
(OleDbDataReader drEMP = cmdEMP.ExecuteReader())
{
dtEMP.Load(drEMP);
dataGridView1.DataSource = dtEMP;
}
}
cnEMP.Close();
}
foreach
(DataGridViewRow EMPRow
in
dataGridView1.Rows)
{
patchmdb = Application.StartupPath +
"\\data.mdb"
;
cnEMP.ConnectionString = @
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source="
+ patchmdb;
cnEMP.Open();
OleDbCommand cmdEMP =
new
OleDbCommand();
cmdEMP.Connection = cnEMP;
string
qryEMP =
"INSERT INTO bill([a], [b], [c], [d], [e], [f], [g], [h], [j], [k]) "
;
qryEMP = qryEMP +
"Values('"
+ EMPRow.Cells[0].Value +
"','"
+ EMPRow.Cells[2].Value +
"','"
+ EMPRow.Cells[7].Value +
"','"
+ EMPRow.Cells[8].Value +
"','"
+
null
+
"','"
+
null
+
"','"
+
null
+
"','"
+
null
+
"','"
+
null
+
"','"
+
null
+
"')"
;
cmdEMP.CommandText = qryEMP;
cmdEMP.CommandType = CommandType.Text;
cmdEMP.ExecuteNonQuery();
cnEMP.Close();
}
OleDbConnection connection =
new
OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source="
+ patchmdb);
connection.Open();
OleDbCommand kdvsil =
new
OleDbCommand(
"DELETE FROM bill WHERE Len(Trim(a &''))=0;"
, connection);
kdvsil.ExecuteNonQuery();
connection.Close();
}
https://1drv.ms/u/s!Al0E9WhLjd-q9CuIQE7TjKHA1_HZ
Attachment:
excelltomdb.rar
Reply
Answers (
2
)
redirect to action in another controller in different direct
Object moved to here - C# login page error