Deepak Talwar
New Member
- Joined
- Dec 15, 2014
- Messages
- 1
I want to import XLSX file in SQL database. i am using following C# code.
in one column I have data of more than 255 characters. While reading records in Dataset it pick data up to 255 characters only
<code style="margin: 0px; padding: 0px; border: 0px; font-size: 13.63636302947998px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">OleDbConnection odconn = null
String file = sample.xlsx
odconn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + file + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1;\";");
odconn.Open();
dtCol = oconn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
string strSheetName = dtCol.Rows[0]["TABLE_NAME"].ToString();
odconn.Close();
odconn.Open();
OleDbDataAdapter oleda = new OleDbDataAdapter("select * from [" + strSheetName + "]", odconn);oleda.Fill(ds);
odconn.Close();</code>
in one column I have data of more than 255 characters. While reading records in Dataset it pick data up to 255 characters only
<code style="margin: 0px; padding: 0px; border: 0px; font-size: 13.63636302947998px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;">OleDbConnection odconn = null
String file = sample.xlsx
odconn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + file + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1;\";");
odconn.Open();
dtCol = oconn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
string strSheetName = dtCol.Rows[0]["TABLE_NAME"].ToString();
odconn.Close();
odconn.Open();
OleDbDataAdapter oleda = new OleDbDataAdapter("select * from [" + strSheetName + "]", odconn);oleda.Fill(ds);
odconn.Close();</code>