tags:

views:

98

answers:

1

I can use "!do" to dump the SqlConnection instance but not sure how to find out its ConnectionString:

0:018> !do 2fa7730
Name: System.Data.SqlClient.SqlConnection
MethodTable: 000007fef4455968
EEClass: 000007fef42b6530
Size: 104(0x68) bytes
 (C:\Windows\assembly\GAC_64\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll)
Fields:
              MT    Field   Offset                 Type VT     Attr            Value Name
000007fef80ee580  400018a        8        System.Object  0 instance 0000000000000000 __identity
000007fef7558ff0  40008cc       10 ...ponentModel.ISite  0 instance 0000000000000000 site
000007fef75888d8  40008cd       18 ....EventHandlerList  0 instance 0000000000000000 events
000007fef80ee580  40008cb      210        System.Object  0   static 0000000002769b58 EventDisposed
000007fef4966d98  4000be5       20 ...hangeEventHandler  0 instance 0000000000000000 _stateChangeEventHandler
000007fef49789e0  400172c       28 ...t.SqlDebugContext  0 instance 0000000000000000 _sdc
000007fef80ede60  400172d       58       System.Boolean  1 instance                0 _AsycCommandInProgress
000007fef445c100  400172e       30 ...ent.SqlStatistics  0 instance 0000000000000000 _statistics
000007fef80ede60  400172f       59       System.Boolean  1 instance                0 _collectstats
000007fef80ede60  4001730       5a       System.Boolean  1 instance                0 _fireInfoMessageEventOnUserErrors
000007fef4459458  4001733       38 ...ConnectionOptions  0 instance 0000000002fa7798 _userConnectionOptions
000007fef4458b68  4001734       40 ...nnectionPoolGroup  0 instance 0000000002fa7b28 _poolGroup
000007fef44596a0  4001735       48 ...onnectionInternal  0 instance 0000000002fa9130 _innerConnection
000007fef80f5f00  4001736       50         System.Int32  1 instance                0 _closeCount
000007fef80f5f00  4001738       54         System.Int32  1 instance             8863 ObjectID
000007fef80ee580  400172b      f30        System.Object  0   static 00000000027885a8 EventInfoMessage
000007fef4458860  4001731      f38 ...ConnectionFactory  0   static 00000000027885c0 _connectionFactory
000007fef80f5658  4001732      f40 ...eAccessPermission  0   static 000000000278f910 ExecutePermission
000007fef80f5f00  4001737      9c0         System.Int32  1   static            16803 _objectTypeCount
+2  A: 

try visual studio 2008 debuger, debug a program which uses SqlConnection;

find the SqlConnection instance in your favorate way (it could be local var, or instance fields, or static fields..).

view it in the Watch window. expand it's every expandable child notes, untill you find what you want(as I can remember it stores parts like server, database, userid, password and so on seperately ).

record the path to how you navigate to these fields, then use windbg to go to the same field.

deerchao
Thank you. This reminded me to use Reflector to check the data and found it's _userConnectionOptions._usersConnectionString.
wangzq