Advertisement

05.26.2008 at 02:31AM PDT, ID: 23432325
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.9

Import excel file and force format columns

Asked by mark_norge in Visual Basic Programming

Tags:

Hi Experts,
I import an Excel file to a data table. The import works, however I am missing data from some columns. It seems that these columns have in common that they have numeric and alphanumeric data (all the alphanumeric data is missing). One column in the Excel sheet is for instance:
Size (header)
300
350
45/50 (this one is missing)
300

It looks like Visual Basic by default recognized the header and uses the second value to determine the data type.

Is there a way to force the data format for each column (integers, strings and dates) and to specify if the first row contains headers? Attached the code I use to import the Excel file.

Help is as always appreciated.
Regards, MBStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
Dim ImportBookingDS As DataSet
        Try
            Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & ImportDir & ImportBookingFile & ";" & "Extended Properties=Excel 8.0;"
 
            Dim objConn As New OleDbConnection(strConn)
            objConn.Open()
 
            Dim objCmd As New OleDbCommand("SELECT * FROM [Sheet1$]", objConn)
 
            Dim objDA As New OleDbDataAdapter()
            objDA.SelectCommand = objCmd
 
            ImportBookingDS = New DataSet()
            objDA.Fill(ImportBookingDS, "ImportBookings")
 
            objConn.Close()
        Catch ex As Exception
            MsgBox("The following error occured " & ex.Message, MsgBoxStyle.Exclamation) 'Possible errors include Excel file already open, locked, etc
        End Try
 
        Me.DataGridView8.DataSource = ImportBookingDS.Tables("ImportBookings")
[+][-]05.27.2008 at 06:02AM PDT, ID: 21651469

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.31.2008 at 11:31AM PDT, ID: 21684618

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.01.2008 at 04:27AM PDT, ID: 21686619

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 01:02PM PDT, ID: 21695162

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Visual Basic Programming
Tags: visual basic .net
Sign Up Now!
Solution Provided By: LIONKING
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628