Excel VBA: Late binding reference -


I'm trying to write some code for some add-ins in Excel, which takes some data from a SQL Server is. This code is working perfectly, but somehow something has become corrupt.

It looks like the code will work properly and then suddenly there will be an excel-crash trigger. After a long time I have come to be something of contexts, such as changes crashes I refer to something else "Microsoft Aktivak Data Objects 2.8 Library" on me, and then back again, add-these will work To

Seeing the add-in as a rebuilding does not work, I'm beginning to find out the option of late bondage. I can not understand how to do this.

  private sub RetrieveToWorksheet (SQL string, WriteTo as range, optional WriteColumnNames Boolean = true as) GetStatus = in "True" Then MsgBox ( "database currently update being. Later, try again. ") Exit sub end if Application.ScreenUpdating = false dim connection ADODB.Connection dim RecordSet as ADODB.Recordset long as dim RowOffset ADODB.Field as dim area Timelapse ColumnOffset by then error goto final form Err.Clear set connection = no E ADODB AS. Connection ConnectionkConnectionTimeout = 300 ConnectionkCommandTimeout = 300 = ConnectionkConnectionString "Provider = SQLOLEDB; Data Source = vdd1xl0001; initial catalog = SRDK; User ID = SRDK_user; password = password Connect timeout = 300" Connection.Mode = adModeShareDenyNone Connection .Open Set RecordSet = New ADODB.Recordset RecordSet.CursorLocation = adUseServer RecordSet.Open SQL, Connection, ADODB.CursorTypeEnum.adOpenForwardOnly RowOffset = 0 ColumnOffset = 0 If WrittenColumnNames = true then Reco is the rdSet.Fields WriteTo for each field. Cells (1, 1) .Offset (RowOffset, ColumnOffset) .Value = Field.Name ColumnOffset = ColumnOffset + 1 Next ColumnOffset = 0 RowOffset = 1 End then WriteTo .Cells (1, 1) .Offset (RowOffset, ColumnOffset) .CopyFromRecordset RecordSet finalized: No RecordSet not then nothing RecordSet.State = ADODB.ObjectStateEnum.adStateClosed then RecordSet.Close not set RecordSet = something finally No connection is nothing if not Connection.State = ADODB.ObjectStateEnum .adStateClosed then connections. Closed connection = nothing end if Err.Number & lt; & Gt; 0 then error.Rise error Number, error Source, error. Description End Sub  

Long story short: I just want to add an auto-reference to the add-in 'Microsoft ActiveWeb Data Objects 2.8 Library'.

All help is appreciated!

The question about late binding in the answer, in this involves changing the line of code

  ADODB Connection as mist connection  
with

   

and

  set connection = new ADODB.Connection  

the

object as Dim connection
  set connection = GetObject (together, "ADODB.Connection")  

And similarly for that object to other objects.

Now, I am not sure it will correct the real problem you are making. It seems that there is a bug in the ActiveX library and you're hitting it, though you are doing nothing particularly esoteric.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -