Click here to Skip to main content
15,913,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:


Hello I am Emmanuel and I have developed, compiled and installed an application. Everything works perfectly until I make an update. I get the error: "length cannot be less than zero. parameter name: length". Can someone help me out. Thanks

Posted
Updated 18-Oct-12 23:30pm
v2
Comments
Ambesha 19-Oct-12 5:35am    
please share your code
[no name] 19-Oct-12 6:08am    
You need to make the length parameter greater then zero when calling the function where you are getting the error.

1 solution

 
Share this answer
 
Comments
Member 4146005 19-Oct-12 5:48am    
Thanks Ambesha for the help.
The issue still exists. will try again.
Ambesha 19-Oct-12 5:51am    
Better share ur cods part here..
Member 4146005 19-Oct-12 6:12am    
Ok. here is it.

On click of the save button, i check if the item being saved already exist in the database.

Public Function save() As String
Try
''RegDate = Today.Date

'If Not ConnectionState.Closed Then _con.Close()
'Connect()
blnResult = CheckExist(ClientNumber)
If blnResult = True Then
'Begin the Transaction
_trans = _con.BeginTransaction(IsolationLevel.ReadCommitted)
'_com.Transaction = _trans

'Update Client
query = "Update tblClients Set fldFirstName = '" & Replace(FirstName, "'", "''") & "', fldLastName = '" & Replace(LastName, "'", "''") & "', " & _
"fldTitle = '" & Replace(Title, "'", "''") & "',fldFullName = '" & Replace(FullName, "'", "''") & "', " & _
"fldGender = '" & Replace(Gender, "'", "''") & "', fldBirthDate = '" & Replace(BirthDate, "'", "") & "', " & _
"fldAddress = '" & Replace(Address, "'", "''") & "', fldPhone1 = '" & Replace(PhoneNumber1, "'", "") & "', " & _
"fldPhone2 = '" & Replace(PhoneNumber2, "'", "") & "', fldHomeTown = '" & Replace(HomeTown, "'", "''") & "', " & _
"fldMaritalStatus = '" & Replace(MaritalStatus, "'", "''") & "', " & _
"fldSpouse = '" & Replace(SpouseName, "'", "''") & "', fldSpousePhone = '" & Replace(SpousePhone, "'", "") & "', " & _
"fldNextOfKin = '" & Replace(NextOfKin, "'", "''") & "', " & _
"fldPhoto = '" & Replace(PictureName, "'", "''") & "', fldDate = '" & Replace(RegDate, "'", "") & "' Where fldClientNo = '" & Replace(ClientNumber, "'", "") & "'"
'_con.Open()
_com = New OleDb.OleDbCommand(query, _con)
_com.Transaction = _trans
ctr = _com.ExecuteNonQuery()


'ContextUtil.SetComplete()
'Commit the transaction
_trans.Commit()
blnSuccess = True

'_con.Close()
MessageBox.Show("New Client saved", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Catch nullEx As NullReferenceException
MessageBox.Show(nullEx.Message)
'Rollback the transaction
'ContextUtil.SetAbort()
_trans.Rollback()
blnSuccess = False
Catch ex As Exception
MessageBox.Show(ex.Message)
'Rollback the transaction
'ContextUtil.SetAbort()
_trans.Rollback()
blnSuccess = False
'_con.Close()
End Try
Return blnSuccess
End Function

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900