arithmetic operation resulted in an overflowhttp://forums.asp.net/t/307140.aspx/1?arithmetic+operation+resulted+in+an+overflowTue, 12 Aug 2003 18:57:44 -0400307140307140http://forums.asp.net/p/307140/307140.aspx/1?arithmetic+operation+resulted+in+an+overflowarithmetic operation resulted in an overflow Please help, I am using a html file field to upload an image to sql server. I keep on getting an error on this line of my code: Error: arithmetic operation resulted in an overflow Dim imgBinaryData As Byte() = New Byte() {imgLen} here is my code: myConnection = New SqlConnection(ConfigurationSettings.AppSettings(&quot;ConnectionString&quot;)) Dim InsertCommand As SqlCommand = New SqlCommand() InsertCommand.Connection = myConnection If Page.IsValid Then Dim imgStream As Stream = BrideImages.PostedFile.InputStream * Dim imgLen As Integer = BrideImages.PostedFile.ContentLength Dim imgContentType As String = BrideImages.PostedFile.ContentType Dim imgName As String = Trim(txtFileName.Text) * Dim imgBinaryData As Byte() = New Byte() {imgLen} Dim n As Integer = imgStream.Read(imgBinaryData, 0, imgLen) Dim RowsAffected As Integer = SaveToDB(imgName, imgBinaryData, imgContentType) If (RowsAffected &gt; 0) Then Response.Write(&quot;<br> The Image was saved&quot;) Else Response.Write(&quot;<br> An error occurred uploading the image&quot;) End If End If End Sub Private Function SaveToDB(ByVal imgName As String, ByVal imgbin As Byte(), ByVal imgContentType As String) As Integer myConnection = New SqlConnection(ConfigurationSettings.AppSettings(&quot;ConnectionString&quot;)) Dim InsertCommand As SqlCommand = New SqlCommand() InsertCommand.Connection = myConnection InsertCommand.CommandText() = &quot;INSERT INTO T_Brides (bFullName, gFullName, Email, Address, City, State, Zip, Phone, Fax, EventDate, imgName, imgData, imgContentType)&quot; _ &amp; &quot;VALUES ('&quot; &amp; Trim(txtbFullName.Text) &amp; &quot;', '&quot; &amp; Trim(txtGFullName.Text) &amp; &quot;', '&quot; &amp; Trim(txtEmail.Text) &amp; &quot;', &quot; _ &amp; &quot; '&quot; &amp; Trim(txtAddress.Text) &amp; &quot;', '&quot; &amp; Trim(txtCity.Text) &amp; &quot;', '&quot; &amp; Trim(txtState.Text) &amp; &quot;', '&quot; &amp; Trim(txtZip.Text) &amp; &quot;', &quot; _ &amp; &quot; '&quot; &amp; Trim(txtPhone.Text) &amp; &quot;', '&quot; &amp; Trim(txtFax.Text) &amp; &quot;', '&quot; &amp; Trim(txtEventDate.Text) &amp; &quot;', @imgName, @imgData, @ImgContentType)&quot; Dim param0 As SqlParameter = New SqlParameter(&quot;@imgName&quot;, SqlDbType.VarChar, 50) param0.Value = imgName InsertCommand.Parameters.Add(param0) Dim param1 As SqlParameter = New SqlParameter(&quot;@imgData&quot;, SqlDbType.Image) param1.Value = imgbin InsertCommand.Parameters.Add(param1) Dim param2 As SqlParameter = New SqlParameter(&quot;@imgContentType&quot;, SqlDbType.VarChar, 50) param2.Value = imgContentType InsertCommand.Parameters.Add(param2) myConnection.Open() Dim numRowsAffected As Integer = InsertCommand.ExecuteNonQuery() myConnection.Close() Return numRowsAffected End Function 2003-08-12T18:18:24-04:00