Click here to Skip to main content
15,909,822 members

Comments by AshishvermaMCA (Top 13 by date)

AshishvermaMCA 12-May-15 8:00am View    
Thanks Maciej Los
For giving solution.
AshishvermaMCA 12-May-15 3:44am View    
Hi Maciej Los,
I will face one more problem when i an using OleDbCommand cmd = new OleDbCommand("SELECT ColumnName1, ColumnName2, ColumnNameX FROM [" + dt.ToString() + "]", oledbConn);


because if user change the column name in Excel file then how i will handle this.
AshishvermaMCA 12-May-15 3:42am View    
No I can't replace - SELECT * FROM [" + dt.ToString() + "] with SELECT ColumnName1, ColumnName2, ColumnNameX FROM [" + dt.ToString() + "]

Actually my objective is When i am going to upload Excel file need to check excel columns is exact with my column which is used in code like
ds.Tables[0].Rows[i]["ColumnName1"].ToString();
AshishvermaMCA 12-May-15 3:18am View    
I am using this code to take data from excel file-


oledbConn.Open();
object dt = oledbConn.GetSchema("Tables").Rows[0]["TABLE_NAME"];

OleDbCommand cmd = new OleDbCommand("SELECT * FROM [" + dt.ToString() + "]", oledbConn);
OleDbDataAdapter oleda = new OleDbDataAdapter();
oleda.SelectCommand = cmd;
oleda.Fill(ds, "WellCareMCD");
oledbConn.Close();
AshishvermaMCA 3-Nov-14 6:44am View    
All records which are displayed into Grid View.
Suppose 20 records is displayed . I need to save 20 records into database sql server on a click of button without implementing loop functionality.