I tried it but got error at .CommandText ....Please help....
Set cn = New ADODB.Connection
With cn
..ConnectionString = "Provider=sqloledb;" & _
"Data Source=myServer;" & _
"Initial Catalog=myDatabase;" & _
"User Id=myUsername;" & _
"Password=myPassword"
..CursorLocation = adUseClient
..Open
End With
Set cd = New ADODB.Command
With cd
Set .ActiveConnection = cn
..CommandType = adCmdText
..CommandText = "SELECT * " & _ I got
problem when it get to here"FROM dbo.mytable m WITH (NOLOCK) " & _
"WHERE m.ID=" & Range("A1").Value
Set rs = .Execute
End With
Range("A2").CopyFromRecordset rs
rs.Close
Set rs = Nothing
Set cd = Nothing
cn.Close
Set cn = Nothing
End Sub
--
canix
------------------------------------------------------------------------
canix's Profile:
http://www.excelforum.com/member.php...o&userid=25962
View this thread:
http://www.excelforum.com/showthread...hreadid=394289