This is my query string
dim strSQLUpdate as String = _
"Update [tblSupplier] SET [SupplierName] =@.SupplierName, " & _
"[Address1] =@.Address1, [Address2] =@.Address2, [State] =@.State, " & _
"[Postcode] =@.Postcode, [Telephone] =@.Telephone, [Fax]=@.Fax, [Mobile] =@.Mobile " & _
"WHERE [SupplierID] =@.SupplierID"
Problem: if one of the fields eg Fax or Mobile is EMPTY (this is OK with the database) then the following error occurs
Field 'tblSupplier.Fax' cannot be a zero-length string.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: Field 'tblSupplier.Fax' cannot be a zero-length string.
Source Error:
Line 136: comm.Parameters.Add(paramSupplierId)
Line 137:
Line 138: comm.ExecuteNonQuery()
Line 139:
Line 140: conn.Close
Kathy
Look at your database design - - if you want to allow zero length strings, it must be set up that way in the table - - if not, you will get this error for every field that does not allow it, when the field is blank.
You can also use a Try/Catch block to make a 'prettier' presentation of the error. Most of that depends on what you actually want to happen when this problem occurs
OK. My database is set up to allow zero length strings and the Web form will process this type of data from the database, but if I UPDATE the execute query doesn't like it. These fields are optional as some suppliers have fax and mobile (cell phones) details and others do not.
Can you help me out with the Try/Catch block? I am assuming I say something along the lines ... IF all fields are not empty then accept, if not then make those empty fields?
Kathy
OK... it works now. I didn't have the field property set to accept zero strings. THANKS.
Kathy
No comments:
Post a Comment