NEED HELP~!
Does anyone know how to import exel data into sql server using vb.net? I want to create a openfiledialog and allow user to choose which exel file to be imported into the server.
Thank you so much~~ >.<
PS. I am just a beginner of vb.net. So would u pls tell me the solution in detail?
THANKS~~~!!
Aviplo
0
Light Poster
Recommended Answers
Jump to PostTry Dim fBrowse As New OpenFileDialog With fBrowse .Filter = "Excel files(*.xls)|*.xls|All files (*.*)|*.*" .FilterIndex = 1 .Title = "Import data from Excel file" End With If fBrowse.ShowDialog() = Windows.Forms.DialogResult.OK Then Dim fname As String fname = fBrowse.FileName Dim MyConnection As System.Data.OleDb.OleDbConnection Dim DtSet As System.Data.DataSet Dim …
Jump to Postdo i have to replace it with my column name in sql server
yes you do. That was a sample code given to you by pgmer as he cant say exactly what the columns in your excel sheet are so you have to fix them in.
Jump to Postselect Columns names from [sheet$]
Columns names are you column names in excel and Sheet$ is the name of ur sheet in excel from where you want to import. If it is one time activivty do it using Maping from SQL wizard or else write code as shown above...
Jump to PostAviplo, you're welcome.
Jump to Post"select B from Menu_templateจ้า"
i cant even pick the name of your excel sheet let alone your computer. You can simply use the wizard in SSMS. It may save you the stress except you want to do with codes for some reasons best known to you
All 17 Replies
Pgmer
50
Master Poster
Featured Poster
Aviplo
0
Light Poster
Aviplo
0
Light Poster
Netcode
33
Veteran Poster
Aviplo
0
Light Poster
Pgmer
50
Master Poster
Featured Poster
Netcode
33
Veteran Poster
Aviplo
0
Light Poster
Netcode
33
Veteran Poster
Aviplo
0
Light Poster
Aviplo
0
Light Poster
Aviplo
0
Light Poster
Netcode
33
Veteran Poster
Pgmer
50
Master Poster
Featured Poster
Aviplo
0
Light Poster
Netcode
33
Veteran Poster
Aviplo
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.