|
Iam using like the following
ExcelFile="C:\temp\My_test.xls"
Dim strConn As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & ExcelFile & "; Extended Properties=""Excel 8.0; HDR=Yes; IMEX=1"""
Dim excelsheet As String = "[Sheet1$]"
Dim sql As String = "SELECT * FROM " & excelsheet
Try
Using cn As New OleDb.OleDbConnection
cn.ConnectionString = strConn
Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(sql, cn)
cn.Open()
da.Fill(items)
cn.Close()
End Using
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
|
|
|
|
|
Sorry,I'm not going to read all the Sheet1 information into my datagirdview,because I doesn't need the additional data inside the sheet1. I would like to just retrieve the table data into my DataGridView. My 1st row header column for the table in my Excel sheet are A4:G4, the details of each row of data are from A5:G5. Can I know how to do this retrieving of data into my DataGridView?
Hope someone can guide me better. Thank you~!
Regards
Drex
|
|
|
|
|
At which line of code it gave you the error?
Shay Noy
modified on Sunday, July 12, 2009 6:55 AM
|
|
|
|
|
Well..The Error appeared at this line>> MyCommand.Fill(DtSet)
What might be the problem?
Thanks ~!
|
|
|
|
|
I made a simulation by changing the name of the Qty column in my excel file and I got the same error message as you got.
The problem is that you do not have a Qty column in your excel file.
You have to change the "Select Qty" in the query to "Select YourNameField"
Shay Noy
|
|
|
|
|
I do have a Qty column located at A3 cell here at Sheet1 actually. But I don't know why can cause this problem. My data is start at A4 column,I cannot put my Qty column to A1 because there is other data in A1 field in my Excel. Do you have any idea how should solve this problem?
Thanks
Regards
Drex
|
|
|
|
|
Have you got data in A1, A2 lines?
If yes you must leave those lines blank.
Try it and reply
Shay Noy
|
|
|
|
|
No,it was blank field for A1 and A2 field here actually. My table start with A3 actually. Do you have any other way beside this? Is that Interop can help to solve this problem? Do you have sample for using interops?
Thanks~!
Regards
Drex
|
|
|
|
|
I have another way, if you want, by linking the excel table to MS Access and then using access table to continue you project.
But, let's try to understand what you problem is.
If you want send me your excel file by email (helelark@gmail.com) and the button1 code too, I will check and re-send it to you.
Just tell me if you send it too me by email so I will check my email
Shay Noy
|
|
|
|
|
I just email you my Excel file. Hope you can check it for me. Thank you~!
Regards
Drex
|
|
|
|
|
Just remove the 2 first rows, A1 and A2 and it will works fine
Shay Noy
|
|
|
|
|
Yes,but the problem is I must get it work with A4 as the row header. Because I need to grab the data from the OrderingFormat.xls file I have send to you. If I start with A1 as the row header,it won't works in my project. Do you have any other ideas?
Thank you.
Regards
Drex
|
|
|
|
|
Sorry, I saw the second file you sent me only after sending you this reply. I have checked in google and the solution is as following:
select Qty from [Sheet1$A3:C6]...
A3:first column,first row
C6:last column,last row
Good luck
Shay Noy
|
|
|
|
|
Yes,I got the solution now. Thank you so much for your help on this issue Mr. Eric Hilel. I will solve the problem here. Thanks alot for your kind effort.
Regards
Drex
|
|
|
|
|
|
I would like to learn sending the messages inside our LAN like a chat...or Just sending the messages enough.
I came to know Tcpclient & Tcplistener can do that... vb.net 2008
Any helps will be really appreciated...
Thanks
|
|
|
|
|
Google for "VB.NET Chat" and you'll find a ton of projects demonstrating the various techniques you can use.
|
|
|
|
|
Hi, hope I'm posting in the right forum.
Got a question on making a general functions class library that will be used in several applications and asp pages, sometimes running at the same time.
I've looked at a lot of samples on the web and they all show you to create an instance of the classlibrary namespace or the classlibrary class.
IE.
dim obj2 as new mycompany.mynamespace.myclass
dim n2 as integer
n2 = obj2.somefunction(...)
What I did was create my class library and put a class in it and declared a function as sharred, then created my dll.
I don't have to create an instance of it and I can use it like the net framework by just coding
n2 = mycompany.mynamespace.myclass.somefunction(...).
Am I going to run into problems doing it this way?
If so how can it be done?
The net framework does this, I mean once I imports it I don't have to make an instance of it in every function.
All the samples I've seen about class libraries do not use the shared keyword.
Could some explain this to me?
Thanks for allowing me to post. Mark.
|
|
|
|
|
kmas3752 wrote: Am I going to run into problems doing it this way?
No, if the method is static ( shared ), then that is the ONLY way to call it. And if your methods do not have state, then it makes perfect sense to do it this way.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Could you explain 'if your methods do not have state' ?
|
|
|
|
|
Hello Experts!!
I am displaying crystal report by coding,passing parameters in that.
i am displaying report from grid contents when i click on gridview cell then respective record report must display....in this i have problem is when i click first time on grid cell then it display wright record but for second click it shows same previous record........
|
|
|
|
|
you need to add the following line
this is how I do it in C#
cryRpt.Refresh(); //to load the most recent updated report from dataset
|
|
|
|
|
hello...
i m working on vbscrpt code to get the names of Domain ID's which are not logged from 3 months..
Can anybody guide me??
or give me some hints..
because i m seriously blank
i have generated a vbscrpt to check the domain names but cant get through
Domain ID's
pls help!!
purvas
|
|
|
|
|
How about this[^] article? Does it helps?
|
|
|
|
|
THANK YOU VERY MUCH
purvas
|
|
|
|