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
Subin Thomas
NA
4.9k
125.5k
how to find the database name from code ?
Feb 27 2019 12:37 AM
i have one code and i have to find the table from which the data have been retrieved here is the code
private
static
DataSet ImportExcelXLS(string FileName,
bool
hasHeaders)
{
string HDR = hasHeaders ?
"Yes"
:
"No"
;
string strConn =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ FileName +
";Extended Properties=\"Excel 8.0;HDR="
+ HDR +
";IMEX=1\""
;
DataSet output =
new
DataSet();
using
(OleDbConnection conn =
new
OleDbConnection(strConn))
{
conn.Open();
DataTable dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
new
object[] { null, null, null,
"TABLE"
});
foreach (DataRow row in dt.Rows)
{
string sheet = row[
"TABLE_NAME"
].ToString();
OleDbCommand cmd =
new
OleDbCommand(
"SELECT * FROM ["
+ sheet +
"]"
, conn);
cmd.CommandType = CommandType.Text;
DataTable outputTable =
new
DataTable(sheet);
output.Tables.Add(outputTable);
new
OleDbDataAdapter(cmd).Fill(outputTable);
}
}
return
output;
}
Reply
Answers (
9
)
Show the details of a particular column in bootstrap modal
i have issue Another Include() method in mvc