Solved

INDEX ZERO BASED ERROR

Posted on 2010-08-31
5
472 Views
Last Modified: 2013-12-26
I have a form that when submitted I am getting the following message:  Can someone help.

Index (zero based) must be greater than or equal to zero and less than the size of the argument list
Imports System.Net
Imports System.Net.Mail

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim con As New System.Data.OleDb.OleDbConnection

        Dim myPath As String
        myPath = Server.MapPath("database2.mdb")

        con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source=" & myPath & ";"
        Dim myCommand As New System.Data.OleDb.OleDbCommand

        myCommand.CommandText = String.Format("INSERT INTO mel([dates],[station],[shift],[assigned],[completed],[deferred],[workg],[lead],[Ship1],[Log1],[Status1],[MEL1],[Def1],[Part1],[Ship2],[Log2],[Status2],[MEL2],[Def2],[Part2],[Ship3],[Log3],[Status3],[MEL3],[Def3],[Part3],[Ship4],[Log4],[Status4],[MEL4],[Def4],[Part4],[Ship5],[Log5],[Status5],[MEL5],[Def5],[Part5],[Ship6],[Log6],[Status6],[MEL6],[Def6],[Part6],[Ship7],[Log7],[Status7],[MEL7],[Def7],[Part7],[Ship8],[Log8],[Status8],[MEL8],[Def8],[Part8],[Ship9],[Log9],[Status9],[MEL9],[Def9],[Part9],[Ship10],[Log10],[Status10],[MEL10],[Def10],[Part10],[Ship11],[Log11],[Status11],[MEL11],[Def11],[Part11],[Ship12],[Log12],[Status12],[MEL12],[Def12],[Part12],[Ship13],[Log13],[Status13],[MEL13],[Def13],[Part13],[Ship14],[Log14],[Status14],[MEL14],[Def14],[Part14],[Ship15],[Log15],[Status15],[MEL15],[Def15],[Part15],[Ship16],[Log16],[Status16],[MEL16],[Def16],[Part16]) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}','{34}','{35}','{36}','{37}','{38}','{39}','{40}','{41}','{42}','{43}','{44}','{45}','{46}','{47}','{48}','{49}','{50}','{51}','{52}','{53}','{54}','{55}''{56}','{57}','{58}','{59}','{60}','{61}','{62}','{63}','{64}','{65}','{66}','{67}','{68}','{69}','{70}','{71}','{72}','{73}','{74}','{75}','{76}','{77}','{78}','{79}','{80}','{81}','{82}','{83}','{84}','{85}','{86}','{87}','{88}','{89}','{90}','{91}','{92}','{93}','{94}','{95}','{96}','{97}','{98}','{99}','{100}','{101}','{102}','{103}','{104)')", DateTime.Parse(Dates.Text), Station.text, Shift.Text, Assigned.Text, Completed.Text, Deferred.Text, Workg.Text, Lead.Text, Ship1.Text, Log1.Text, Status1.Text, MEL1.Text, Def1.Text, Part1.Text, Ship2.Text, Log2.Text, Status2.Text, MEL2.Text, Def2.Text, Part2.Text, Ship3.Text, Log3.Text, Status3.Text, MEL3.Text, Def3.Text, Part3.Text, Ship4.Text, Log4.Text, Status4.Text, MEL4.Text, Def4.Text, Part4.Text, Ship5.Text, Log5.Text, Status5.Text, MEL5.Text, Def5.Text, Part5.Text, Ship6.Text, Log6.Text, Status6.Text, MEL6.Text, Def6.Text, Part6.Text, Ship7.Text, Log7.Text, Status7.Text, MEL7.Text, Def7.Text, Part7.Text, Ship8.Text, Log8.Text, Status8.Text, MEL8.Text, Def8.Text, Part8.Text, Ship9.Text, Log9.Text, Status9.Text, MEL9.Text, Def9.Text, Part9.Text, Ship10.Text, Log10.Text, Status10.Text, MEL10.Text, Def10.Text, Part10.Text, Ship11.Text, Log11.Text, Status11.Text, MEL11.Text, Def11.Text, Part11.Text, Ship12.Text, Log12.Text, Status12.Text, MEL12.Text, Def12.Text, Part12.Text, Ship13.Text, Log13.Text, Status13.Text, MEL13.Text, Def13.Text, Part13.Text, Ship14.Text, Log14.Text, Status14.Text, MEL14.Text, Def14.Text, Part14.Text, Ship15.Text, Log15.Text, Status15.Text, MEL15.Text, Def15.Text, Part15.Text, Ship16.Text, Log16.Text, Status16.Text, MEL16.Text, Def16.Text, Part16.Text)
        myCommand.Connection = con
        con.Open()
        myCommand.ExecuteNonQuery()
        con.Close()

        'Send Email
        Dim smtpClient As SmtpClient = New SmtpClient()
        Dim message As MailMessage = New MailMessage()
        Dim fromAddress As MailAddress = New MailAddress("LAS@laxpm.com")
        message.From = fromAddress
        message.To.Add("mark@laxpm.com,mark.scherer@allegiantair.com,bruce.magee@allegiantair.com,michael.landry@allegiantair.com,david.abend@allegiantair.com,michael.calderaro@allegiantair.com,charles.chambers@allegiantair.com,kristopher.roper@allegiantair.com,joseph.yancey@allegiantair.com,john.amos@allegiantair.com,calistro.alvarado@allegiantair.com,aj.lapointe@allegiantair.com,frank.lizzio@allegiantair.com,michael.james@allegiantair.com,ian.mohammed@allegiantair.com,dwight.flowers@allegiantair.com,Alan.West@allegiantair.com,Kirk.Kolves@allegiantair.com,Trevor.Grosos@allegiantair.com,kurt.carpenter@allegiantair.com")
        message.Subject = "LAS OVERNIGHT MEL COMPLETION"

        Dim palinBody As String = "Station: " & Station.Text & ", Shift: " & Shift.Text & ", Assigned: " & Assigned.Text & ", Completed: " & Completed.Text & ", Deferred: " & Deferred.Text & ", Workg: " & Workg.Text & ", Lead: " & Lead.Text & ", Ship1: " & Ship1.Text & ", Log1: " & Log1.Text & ", Status1: " & Status1.Text & ", MEL1: " & MEL1.Text & ", Def1: " & Def1.Text & ", Part1: " & Part1.Text & ", Ship2: " & Ship2.Text & ", Log2: " & Log2.Text & ", Status2: " & Status2.Text & ", MEL2: " & MEL2.Text & ", Def2: " & Def2.Text & ", Part2: " & Part2.Text & ", Ship3: " & Ship3.Text & ", Log3: " & Log3.Text & ", Status3: " & Status3.Text & ", MEL3: " & MEL3.Text & ", Def3: " & Def3.Text & ", Part3: " & Part3.Text & ", Ship4: " & Ship4.Text & ", Log4: " & Log4.Text & ", Status4: " & Status4.Text & ", MEL4: " & MEL4.Text & ", Def4: " & Def4.Text & ", Part4: " & Part4.Text & ", Ship5: " & Ship5.Text & ", Log5: " & Log5.Text & ", Status5: " & Status5.Text & ", MEL5: " & MEL5.Text & ", Def5: " & Def5.Text & ", Part5: " & Part5.Text & ", Ship6: " & Ship6.Text & ", Log6: " & Log6.Text & ", Status6: " & Status6.Text & ", MEL6: " & MEL6.Text & ", Def6: " & Def6.Text & ", Part6: " & Part6.Text & ", Ship7: " & Ship7.Text & ", Log7: " & Log7.Text & ", Status7: " & Status7.Text & ", MEL7: " & MEL7.Text & ", Def7: " & Def7.Text & ", Part7: " & Part7.Text & ", Ship8: " & Ship8.Text & ", Log8: " & Log8.Text & ", Status8: " & Status8.Text & ", MEL8: " & MEL8.Text & ", Def8: " & Def8.Text & ", Part8: " & Part8.Text & ", Ship9: " & Ship9.Text & ", Log9: " & Log9.Text & ", Status9: " & Status9.Text & ", MEL9: " & MEL9.Text & ", Def9: " & Def9.Text & ", Part9: " & Part9.Text & ", Ship10: " & Ship10.Text & ", Log10: " & Log10.Text & ", Status10: " & Status10.Text & ", MEL10: " & MEL10.Text & ", Def10: " & Def10.Text & ", Part10: " & Part10.Text & ", Ship11: " & Ship11.Text & ", Log11: " & Log11.Text & ", Status11: " & Status11.Text & ", MEL11: " & MEL11.Text & ", Def11: " & Def11.Text & ", Part11: " & Part11.Text & ", Ship12: " & Ship12.Text & ", Log12: " & Log12.Text & ", Status12: " & Status12.Text & ", MEL12: " & MEL12.Text & ", Def12: " & Def12.Text & ", Part12: " & Part12.Text & ", Ship13: " & Ship13.Text & ", Log13: " & Log13.Text & ", Status13: " & Status13.Text & ", MEL13: " & MEL13.Text & ", Def13: " & Def13.Text & ", Part13: " & Part13.Text & ", Ship14: " & Ship14.Text & ", Log14: " & Log14.Text & ", Status14: " & Status14.Text & ", MEL14: " & MEL14.Text & ", Def14: " & Def14.Text & ", Part14: " & Part14.Text & ", Ship15: " & Ship15.Text & ", Log15: " & Log15.Text & ", Status15: " & Status15.Text & ", MEL15: " & MEL15.Text & ", Def15: " & Def15.Text & ", Part15: " & Part15.Text & ", Ship16: " & Ship16.Text & ", Log16: " & Log16.Text & ", Status16: " & Status16.Text & ", MEL16: " & MEL16.Text & ", Def16: " & Def16.Text & ", Part16: " & Part16.Text & ""



        Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString(palinBody, Nothing, "text/plain")
        Dim htmlBody As String = "Date: " & DateTime.Parse(Dates.Text) & "<p>Station: " & Station.Text & "&nbsp;&nbsp;&nbsp;&nbspShift: " & Shift.Text & "<p>Lead: " & Lead.Text & "<br /><br />Assigned: " & Assigned.Text & "&nbsp;&nbsp;&nbsp;&nbspCompleted: " & Completed.Text & "&nbsp;&nbsp;&nbsp;&nbspDeferred: " & Deferred.Text & "&nbsp;&nbsp;&nbsp;&nbspWorking: " & Workg.Text & "<br /><br /><br /><br />Ship#: " & Ship1.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDMI/Control#: " & Log1.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspMEL Description: " & MEL1.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDeferral Reason: " & Def1.Text & "<br />Part Number/Comments: " & Part1.Text & "<br /><br />Ship#: " & Ship2.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDMI/Control#: " & Log2.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspMEL Description: " & MEL2.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDeferral Reason: " & Def2.Text & "<br />Part Number/Comments: " & Part2.Text & "<br /><br />Ship#: " & Ship3.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDMI/Control#: " & Log3.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspMEL Description: " & MEL3.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDeferral Reason: " & Def3.Text & "<br />Part Number/Comments: " & Part3.Text & "<br /><br />Ship#: " & Ship4.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDMI/Control#: " & Log4.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspMEL Description: " & MEL4.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDeferral Reason: " & Def4.Text & "<br />Part Number/Comments: " & Part4.Text & "<br /><br />Ship#: " & Ship5.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDMI/Control#: " & Log5.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspMEL Description: " & MEL5.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDeferral Reason: " & Def5.Text & "<br />Part Number/Comments: " & Part5.Text & "<br /><br />Ship#: " & Ship6.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDMI/Control#: " & Log6.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspMEL Description: " & MEL6.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDeferral Reason: " & Def6.Text & "<br />Part Number/Comments: " & Part6.Text & "<br /><br />Ship#: " & Ship7.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDMI/Control#: " & Log7.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspMEL Description: " & MEL7.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDeferral Reason: " & Def7.Text & "<br />Part Number/Comments: " & Part7.Text & "<br /><br />Ship#: " & Ship8.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDMI/Control#: " & Log8.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspMEL Description: " & MEL8.Text & "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbspDeferral Reason: " & Def8.Text & "<br />Part Number/Comments: " & Part8.Text & ""
        

        Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(htmlBody, Nothing, "text/html")
        message.AlternateViews.Add(plainView)
        message.AlternateViews.Add(htmlView)
        message.Priority = MailPriority.High
        smtpClient.Host = "mail.laxpm.com"
        smtpClient.Send(message)

        Response.Redirect("http://las.laxpm.com/mel/redirect.aspx")

    End Sub
    Private Sub Completed_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Completed.TextChanged

        Deferred.Text = (CDbl(Assigned.text) - CDbl(Completed.Text) - CDbl(Workg.text))

    End Sub
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Part1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Part1.TextChanged

    End Sub
End Class

Open in new window

0
Comment
Question by:BOEING39
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 22

Expert Comment

by:Om Prakash
ID: 33573311
0
 

Author Comment

by:BOEING39
ID: 33573517
I counted the number of cells and it is correct starting at zero.   The link you sent was for "C"; however, but I was on to that idea that I may not have counted correctly.  Still no help.
0
 
LVL 28

Expert Comment

by:Ark
ID: 33574394
Remove '{104)' from myCommand.CommandText
Actually you have 104 fields and 104 values (103 as ZERO based)
0
 
LVL 11

Expert Comment

by:JoeNuvo
ID: 33575209
refer to above comment.

maybe the correct code should be  '{104}'  not '{104)'
0
 
LVL 11

Accepted Solution

by:
JoeNuvo earned 500 total points
ID: 33575224
ah.. yes, these is 104 values.
so code should reach only {103}

anyway, with your given code.  comma was missing from between 55 & 56

'{55}''{56}'
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question