Help me, How to Upload Excel file in sql2000 with Vb.net

Lazor

New member
Joined
Aug 14, 2007
Messages
2
Programming Experience
1-3
Help me please, How to Upload Excel file in sql2000 with Vb.net

i want to import/ upload my excel'files to sql2000 , i have one button to browse

Private Sub Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


OpenFileDialog1.Title = "Open File"
OpenFileDialog1.InitialDirectory = "c:\"
OpenFileDialog1.Filter = "file Excel| *.xls|file text|*.txt"
OpenFileDialog1.FilterIndex = 2 '
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim read As New StreamReader(OpenFileDialog1.FileName)
TextBox2.Text = read.ReadToEnd
read.Close()
End If

and how about the upload button
i try to tes the excel file in to textfield but i see just !!!
but if i open the .txt file, it's ok
Help me please....Thank you
 
Add a two references to your project:

Microsoft.VisualStudio.Tools.Application.Runtime

Microsoft.Office.Tools.Excel

You should put the following line at the top of your Form1 Class Declaration:

VB.NET:
Imports Microsoft.Office.Tools

Then type Excel. and intellisense will pop-up and you will see all the necessary object to do everything you want with the excel file.

The objects that you will need to use for SQL Server will all be in the System.Data namepsace. Use table adapters for inserting data. Data Readers for quick retrieval of data. Connection Objects to "log on" to the database. Data Sets will act as an offline copy of the data if necessary.

You could also easily set up a connection through the wizard to your SQL Server and many of these objects will become easily available for you.
 
soryyy Mr, I have checked the reference, but i can't find Microsoft.VisualStudio.Tools.Application.Runtime

Microsoft.Office.Tools.Excel

i think it's use in vs2003
how about vs 2005 Mr,
I use Vs.2005
Thanks
 
So do I...

Is it possible that you are using the Express edition? Because then it might not have the office tools and runtime tools because these come only with a certain edition. Not sure, I see them in my project.

But using a streamreader will not work for XLS file. There are other objects if it were a CSV but I have always used the Office Tools for Visual Studio when importing XLS files into my applications. There may be some other object for this. This was just always what I used.
 
Back
Top