I use Linq-to-SQL to insert data开发者_如何学Python in vb.net. When I insert data into SQL Server through a DataGridView it gives error of which column data type is "integer" but when I insert data through textbox it not give any error
So I face problem of datatype "integer" to error of specific cast not valid
Well,
There are a few ways to convert a string to an int. But for a safe conversion I would go int.TryParse(your_string_value, out result_value)
This will give you the chance to handle none int values in a more graceful manner.
Good Luck
Try using CType
someObject.IntegerProperty = CType(myTextBox.Value, Int32)
CType Function
Returns the result of explicitly converting an expression to a specified data type, object, structure, class, or interface.
精彩评论