Reputation: 4277
Actually, I'm trying to build a program that imports data to MySQL from Excel but before it, the user will be able to choose the column which he would import to MySQL like column A, B or F, G, D
Actually, I was trying to use the following query where {0} should be 1st sheet and A the column I would select but I'm getting Object doesn't exist error
Here is the query
Dim sqlquery As String = String.Format("SELECT * FROM [{0}A]", myTableName)
EDIT:
If I specify the range like SELECT * FROM [{0}A1:A111]
all works fine but the issue is that I can't know how much rows have the column A.
Upvotes: 2
Views: 853
Reputation: 192
Try this: F1 is the first column.
Dim sqlquery As String = String.Format("SELECT F1 FROM [{0}]", myTableName)
Got the inspiration from here: Retrieving values of the first column from Excel sheet (file with .xlsm extension) with OleDB
Upvotes: 1