473,811 Members | 2,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to upload excel file in vb.net?

1 New Member
hi,
Anybody help me?I have error "Arithmetic operation resulted in overflow"and how to rectify this.
Try

Dim objOFD As New OpenFileDialog

'Set the Open dialog properties
With objOFD
.Filter = "Excel files (*.xlsx)|*.xlsx |Excel files (*.xls)|*.xls"
.FilterIndex = 1
.Title = "Select excel file to upload"
End With
If (objOFD.ShowDia log = Windows.Forms.D ialogResult.OK) Then
If (MsgBox("Are you sure want to upload this excel file?", MsgBoxStyle.Yes No, "Excel file uploading") = MsgBoxResult.Ye s) Then

Dim xlApp As Excel.Applicati on
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim range As Excel.Range
Dim rCnt As Integer
Dim cCnt As Integer
Dim Obj As Object


' customername = "Newcustome r"

xlApp = New Excel.Applicati onClass
xlWorkBook = xlApp.Workbooks .Open(objOFD.Fi leName.ToString )
xlWorkSheet = xlWorkBook.Work sheets("sheet1" )

range = xlWorkSheet.Use dRange

' For rCnt = 2 To range.Rows.Coun t
For rCnt = 2 To 2
For cCnt = 1 To range.Columns.C ount
Obj = CType(range.Cel ls(rCnt, cCnt), Excel.Range)
' MsgBox(Obj.valu e)
If rCnt = 2 And cCnt = 1 Then
If (Obj.value <> Nothing) Then ContractorName = Obj.value.ToStr ing.Trim Else ContractorName = ""
ElseIf rCnt = 2 And cCnt = 2 Then
If (Obj.value <> Nothing) Then ContractorConta ctno = Obj.value.ToStr ing.Trim Else ContractorConta ctno = ""
End If

Next
Next
insertContracto rName()

MsgBox(Contract orName & " Successfully Updated!", MsgBoxStyle.Inf ormation)
Else
MsgBox(Contract orContactno & " already exists!", MsgBoxStyle.Cri tical)
End If

objOFD.Dispose( )
objOFD = Nothing

End If

Catch ex As Exception
MsgBox(ex.Messa ge)
End Try
Nov 14 '11 #1
0 1442

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1434
by: Thomas.LeBlanc | last post by:
We would like to upload Excel files to SQL Server database server that is exposed through IIS. We are using the http calls from a .Net C# Windows Forms application. This is a prototype, that is why we are using SQL Server through IIS. can anybody point us to some sample code for this? -- Thanks,
2
12720
by: Sreedhar Vankayala | last post by:
Hi, I joined a project where we need to import data from a excel file into sql server via the asp.net. After doing a long research found that #1. Upload Excel file to the server #2. Load or keep the Excel file into the memory #3. Query the excel file and convert into insert queries and execute them via sql server
0
1239
by: powerranger | last post by:
I wrote an asp.net application where I can upload an Excel file to the server and get the data from it to display on my datagrid. The program compile without error. The file loaded on the server without problems. I used OleDb to connect to it. But it gave me an OleDb error saying: Failure creating File. If I go to Window Explore I can see it on the server and can open it in Excel (so not a security issue). After, I added another...
1
4823
by: vic pahilan | last post by:
hi, pls need help. I need to upload excel field to sql server field. the user will choose excel file then i will show the fields inside that excel file then copy it into sql server field. I already done the rest but I dont know how to start coding with the command to upload. i use the listview control for excel same with for sql server to display their fields. hope u can help. tnx n advance
3
8012
by: c676228 | last post by:
Hi everyone, I will develop a program to enroll a group of people on-line. Since we don't have number limitation for the people in the group. I am wondering if there is any company allow people to upload an excel sheet which contains data about the people in the group and the asp program can import the data into the program direclty, so the customer don't have to type each person's info individual sin it's error prone and time consuming...
5
7294
by: vimal.424 | last post by:
Hi......all.... can any body tell me how can we upload excel file & send the excel file data in database. I;m not able to do........please help me...... thanks in advance
0
922
by: minhtran | last post by:
Hi all Please, I am a new ASP.NET, I upload an Excel File in the database, but I have an error as "Invalid Signature" . Please, anyone has a knowledge how to solve this problem and share with me , I appreciate so much for your help. Many thanks in advance for your reading this message.
0
1281
by: minhtran | last post by:
Hi all I have a problem when I upload the Excel file 2007 (file.xlsx) via ASP.NET (VB.NET, C#), but it has no problem to upload the Excel file 2003 (file.xls). Please, anyone can help me to solve this problem? I appreciate so much for your help . Thanks a lot
5
4622
by: priyammaheshwari | last post by:
Hi all, I have a MS Access database in which requests made by people is stored,but a coulmn for cost is left empty which is suppose to be populated by the administrator.Now the administrator wants that there should be some functionality by which he would just have to upload an excel file containing the name and cost per person and the cost should be populated in access database against the respective name of people. I am not able to figure...
0
1376
by: NareshN | last post by:
Hi All, I have this tables.I want to upload excel file data to multiple tables. Excel file consist of EmpName,1 week dates with data(TimeIn and TimeOut). I want to insert EmpName into Employee table based on that i will get ID and i want to insert date into Timesheet table and corresponsding data into same table. Can u tell me how to acheive this. Emp-EmpNo,EmpName,CompaignId
0
9726
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10647
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10384
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10130
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6887
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5553
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4338
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.