bernardmanning
Programmer
Hi,
I've got a win form, which connects to sql server using a dataadapter / dataset / datatable and everything works great.
I've noticed that if I try to update a field on a table in sql server with a value that exceeds the field length I get this error ;
I realise that this is because I'm trying to insert a value that is say 30 characters in length into a field on a table that can only contain 20 characters.
My question is this ;
Whats the best way to prevent this from happening?
I know I can specify a 'maxlength' property on the text box control on the form, but I really don't want this piece of 'validation' to be at the UI level.
Is there someplace else to do this?
I'm using the command builder on the data adapter in order to generate the insert/ update and delete commands. eg
Any ideas / help would be gratefully received !!!
Thanks, Bernard
I've got a win form, which connects to sql server using a dataadapter / dataset / datatable and everything works great.
I've noticed that if I try to update a field on a table in sql server with a value that exceeds the field length I get this error ;
Code:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll
Additional information: System error.
I realise that this is because I'm trying to insert a value that is say 30 characters in length into a field on a table that can only contain 20 characters.
My question is this ;
Whats the best way to prevent this from happening?
I know I can specify a 'maxlength' property on the text box control on the form, but I really don't want this piece of 'validation' to be at the UI level.
Is there someplace else to do this?
I'm using the command builder on the data adapter in order to generate the insert/ update and delete commands. eg
Code:
BindingContext(drawingtable).EndCurrentEdit()
dataadapter.DeleteCommand = commandbuilder.GetDeleteCommand()
dataadapter.UpdateCommand = commandbuilder.GetUpdateCommand()
dataadapter.InsertCommand = commandbuilder.GetInsertCommand()
Dim RowsUpdated As Integer = dataadapter.Update(ds, ds.Tables(0).ToString())
Return RowsUpdated
Any ideas / help would be gratefully received !!!
Thanks, Bernard