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
Rishi Chatterjee
NA
116
5.1k
Validate Excel Row with Database Row
Apr 18 2020 2:12 AM
Dear All,
I want to validate Excel Row(UserId) with Database Row(UserId), If it is match then you will insert data other wise through message. I need to fetch all the data in excel row by User Id.
private void Import1()
{
try
{
if (FileUpload1.HasFile)
{
string path = Path.GetFileName(FileUpload1.FileName);
path = path.Replace(" ", "");
FileUpload1.SaveAs(Server.MapPath("~/ExcelFile/") + path);
String ExcelPath = Server.MapPath("~/ExcelFile/") + path;
OleDbConnection OleDbcon = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + ExcelPath + "; Extended Properties=Excel 8.0; Persist Security Info = False");
OleDbcon.Open();
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Sheet1$] ", OleDbcon);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter(cmd);
ds = new DataSet();
objAdapter1.Fill(ds);
Dt = ds.Tables[0];
}
}
catch (Exception ex)
{
}
}
private void Import2( )
{
SqlConnection con2 = new SqlConnection(ConfigurationManager.ConnectionStrings["Connection String"].ConnectionString);
con2.Open();
SqlCommand cnn = new SqlCommand(
"select * from Units Where UserId=70
", con2);
SqlDataAdapter adapter = new SqlDataAdapter(cnn);
dt1 = new DataTable();
adapter.Fill(dt1);
}
}
catch (Exception ex)
{
}
}
private void Check()
{
try
{
for( int i = 0; i < Dt.Rows.Count; i++)
{
for(int j=0; j< dt1 .Rows.Count;j++)
{
if (Dt.Rows[i][0].ToString() != dt1.Rows[j][0].ToString())
{
int RowNo = i + 2;
Response.Write("Employee Id Not Match '" + RowNo + "'");
return;
}
}
}
Reply
Answers (
3
)
user account page in asp.net
Form based authentication using emailid and domain name