Click here to Skip to main content
15,910,009 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionSystem.Data.OleDb & Microsoft Excel Pin
shopi3013-Nov-06 13:48
shopi3013-Nov-06 13:48 
Questionrunning Visual studio application Pin
7prince13-Nov-06 12:22
7prince13-Nov-06 12:22 
AnswerRe: running Visual studio application Pin
Christian Graus13-Nov-06 13:23
protectorChristian Graus13-Nov-06 13:23 
GeneralRe: running Visual studio application Pin
7prince14-Nov-06 6:03
7prince14-Nov-06 6:03 
GeneralRe: running Visual studio application Pin
Christian Graus14-Nov-06 9:44
protectorChristian Graus14-Nov-06 9:44 
GeneralRe: running Visual studio application Pin
7prince14-Nov-06 12:11
7prince14-Nov-06 12:11 
AnswerRe: running Visual studio application Pin
shopi3013-Nov-06 13:49
shopi3013-Nov-06 13:49 
QuestionLoad DataGrid from Excel File Pin
alexfromto13-Nov-06 5:59
alexfromto13-Nov-06 5:59 
Hi.

Last week I posted a question regarding reading Excel file and loading it into the DataGrid.
I didn't get any useful response back so please forgive me for posting this second time.
I'm sure someone had the same problem I have.

I have 3 columns in Excel. One of the columns (User Id) has text data (like: User 1) or a number data (like: 12345). My code works and doesn't throw any error but for some reason it only extracts text data. The numbers are missing and I'm not sure why. I've tried to foramt that columnt to TEXT only but it doesn't help. Just to be sure I looped through DataSet to make sure the values are there and of course they weren't.

Here's the code that reads Excel and loads data into DataGrid. Please help.

Thank you.

Try<br />
'Create DataSet and DataAdapter<br />
ds = New System.Data.DataSet<br />
da = New System.Data.OleDb.OleDbDataAdapter<br />
<br />
'Establish connection<br />
con = New System.Data.OleDb.OleDbConnection( _<br />
"provider=Microsoft.Jet.OLEDB.4.0; " & _<br />
"data source=" & Session("ExcelFilePath").ToString() & "; " & _<br />
"Extended Properties=Excel 8.0")<br />
<br />
'Create command<br />
cmdSelectExcel = New System.Data.OleDb.OleDbCommand("SELECT * FROM [Sheet1$] ORDER BY Company", con)<br />
<br />
'Open connection<br />
con.Open()<br />
<br />
'Exectue command through adapter<br />
da.SelectCommand = cmdSelectExcel<br />
da.Fill(ds, "[Sheet1$]")<br />
<br />
'Assign DataSourse of the DataGrid and bind it<br />
dg.DataSource = ds.Tables(0).DefaultView<br />
dg.DataBind()<br />
<br />
'Close Connection<br />
con.Close()<br />
Catch ex As Exception<br />
'Display error message<br />
lblError.Text = "Error: " & ex.ToString()<br />
lblError.Visible = True<br />
End Try 

AnswerRe: Load DataGrid from Excel File Pin
shopi3013-Nov-06 13:46
shopi3013-Nov-06 13:46 
GeneralRe: Load DataGrid from Excel File Pin
alexfromto14-Nov-06 3:19
alexfromto14-Nov-06 3:19 
QuestionVB.Net 2003 - ItemDataBound Pin
DDscales13-Nov-06 5:37
DDscales13-Nov-06 5:37 
AnswerRe: VB.Net 2003 - ItemDataBound Pin
shopi3013-Nov-06 14:00
shopi3013-Nov-06 14:00 
GeneralRe: VB.Net 2003 - ItemDataBound Pin
DDscales15-Nov-06 8:28
DDscales15-Nov-06 8:28 
QuestionAutoRefresh Pin
Tim8w13-Nov-06 5:30
Tim8w13-Nov-06 5:30 
AnswerRe: AutoRefresh Pin
Christian Graus13-Nov-06 12:15
protectorChristian Graus13-Nov-06 12:15 
AnswerSolved: AutoRefresh Pin
Tim8w14-Nov-06 5:23
Tim8w14-Nov-06 5:23 
Questionsetting text properties Pin
dianadcx13-Nov-06 4:50
dianadcx13-Nov-06 4:50 
AnswerRe: setting text properties Pin
Christian Graus13-Nov-06 12:15
protectorChristian Graus13-Nov-06 12:15 
GeneralRe: setting text properties Pin
dianadcx14-Nov-06 3:05
dianadcx14-Nov-06 3:05 
Questionnumeric Pin
jds120713-Nov-06 4:13
jds120713-Nov-06 4:13 
AnswerRe: numeric Pin
Tim Carmichael13-Nov-06 5:22
Tim Carmichael13-Nov-06 5:22 
GeneralRe: numeric Pin
jds120713-Nov-06 5:38
jds120713-Nov-06 5:38 
GeneralRe: numeric Pin
Tim Carmichael13-Nov-06 5:43
Tim Carmichael13-Nov-06 5:43 
AnswerRe: numeric Pin
DDscales13-Nov-06 7:01
DDscales13-Nov-06 7:01 
QuestionSending program output directly to printer. Pin
Omo Code13-Nov-06 3:02
Omo Code13-Nov-06 3:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.