Public Function InsertSQLwithVars(ByVal strsql As String, ByVal vars As ArrayList, ByRef lex As LastException) As Boolean Dim SQLCeAdapter As System.Data.SqlServerCe.SqlCeDataAdapter = Nothing Dim sparm As SqlServerCe.SqlCeParameter Dim retval As Boolean = True Dim sqlcomm As New SqlServerCe.SqlCeCommand sqlcomm.Connection = _conobj sqlcomm.CommandText = strsql Dim affrows As Integer = 0 Try SQLCeAdapter = New System.Data.SqlServerCe.SqlCeDataAdapter(strsql, _conobj) SQLCeAdapter.InsertCommand = sqlcomm For Each sparm In vars SQLCeAdapter.InsertCommand.Parameters.Add(sparm) Next affrows = SQLCeAdapter.InsertCommand.ExecuteNonQuery() Catch ex As Exception retval = False lex.ErrorMessage = ex.Message If Not ex.InnerException Is Nothing Then lex.ErrorMessage = lex.ErrorMessage & vbCrLf & ex.InnerException.Message End If Finally SQLCeAdapter.Dispose() End Try Return retval End Function
Gain unlimited access to on-demand training courses with an Experts Exchange subscription.Get Access
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE
Connect with Certified Experts to gain insight and support on specific technology challenges including: