Hi,
In my excel sheet1 I have some records. The column name xyz contains some alphanumeric text and smoe pure numbers.
When I do select xyz from [sheet1$] it shows me only numbers and not the alphanumeric text.
I tried formatting the entire column into text and again fired the query I still not resolved the problem
satalaj
Star
10505 Points
2031 Posts
MVP
Excel select xyz from [sheet1$]
Apr 23, 2008 12:41 PM|LINK
Hi,
In my excel sheet1 I have some records. The column name xyz contains some alphanumeric text and smoe pure numbers.
When I do select xyz from [sheet1$] it shows me only numbers and not the alphanumeric text.
I tried formatting the entire column into text and again fired the query I still not resolved the problem
Thanks
kumarkiran
Participant
816 Points
160 Posts
Re: Excel select xyz from [sheet1$]
Apr 23, 2008 01:29 PM|LINK
Hi
try
CAST('xyz' AS nvarchar(25))
Kumar Kiran | Protocols Of Matrix |
Click "Mark as Answer" on the post that helped you to help future readers to get the solutions.
satalaj
Star
10505 Points
2031 Posts
MVP
Re: Excel select xyz from [sheet1$]
Apr 23, 2008 03:00 PM|LINK
Not working
string connectionString = "Provider=Microsoft.JET.OLEDB.4.0;" + "Data Source=" + @"c:\xxx.xls" + ";" + "Extended Properties=Excel 8.0;"; OleDbConnection connection = new OleDbConnection(connectionString); OleDbCommand command = new OleDbCommand("select CAST([A/C Code] as nvarchar(25)) from [sheet1$]", connection); /// This is wrongcommand.Connection.Open();
System.Data.DataTable dt = new DataTable();dt.Load(command.ExecuteReader());
command.Connection.Close();
Satalaj
satalaj
Star
10505 Points
2031 Posts
MVP
Re: Excel select xyz from [sheet1$]
Apr 23, 2008 03:48 PM|LINK
This Thread of www.asp.net has given a solution.
especially rstepan post.
http://forums.asp.net/p/1039391/1443853.aspx#1443853
http://forums.asp.net/tags/Excel+IMEX/default.aspx
Thanks