Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Re: DB update


Message #1 by "Lou Feicht" <lfeicht@f...> on Fri, 5 Oct 2001 15:53:56
Here's the rest, modified from Wrox Pro ASP.NET

Sub ExecuteSQLStatement(strSQL)
	'Dim strConnect As String  = 
ctlConnectStrings.OLEDBConnectionString

	  'create a new Connection object using the connection string
	  Dim objConnect As New OleDbConnection(strConnect)

	  'create a new Command using the connection object and select 
statement
	  Dim objCommand As New OleDbCommand(strSQL, objConnect)

	  'declare an Integer variable to hold the number of records 
affected
	  Dim intRowsAffected As Integer

	  Try

		 'open the connection to the database
		 objConnect.Open()

		 'execute the SQL statement against the command
		 'the ExecuteNonQuery method returns the number of records 
affected
		 intRowsAffected = objCommand.ExecuteNonQuery()

	  Catch objError As Exception

		 'display error details
		 outError.InnerHtml = "<b>* Error while updating original 
data</b>.<br />" _
			 & objError.Message & "<br />" & objError.Source
		 Exit Sub  ' and stop execution

	End Try

	objConnect.close
	objConnect=nothing
End Sub

  Return to Index