Question : Textcopy with trusted connection and Windows authentication

Hello,

I can successfully put an image into SQL Server using Access and a stored procedure that calls Textcopy when specifying a user name and password.

What I would like is to do this without specifying the username and password and having the credentials of the user already logged in given to textcopy so permissions and auditing etc. are correct.
When attempting to do this, Textcopy returns an error saying I didn't specify a username or passwod (which is true, as it is supposed to default to the trusted connection, but it doesn't).
I have tried to pass suser_sname() as a parameter but I am sure there is no way to pass the password as a parameter.

Is my only option to create a user in the database specifically for the purpose of updating images and statically pass the username and password from Access to the stored procedure to Textcopy? Or is there a way to get Textcopy to work with trusted connections through Access/stored procedures?
If any more information is required, please let me know.

Many thanks,
Neil.

Answer : Textcopy with trusted connection and Windows authentication

>>but I don't know another method to use to get images into the database instead of Textcopy. <<
You just reverse out your code using the Stream object as in:

Sub AddImage(rs As ADODB.Recordset, ByVal FileName As String)
Dim stm As ADODB.Stream

Set stm = New ADODB.Stream
With stm
  .Type = adTypeBinary
  .Open
  .LoadFromFile FileName
 
  'Insert the binary object into the table.
  rs.AddNew
  rs.Fields("ImageColumnName").Value = .Read
  rs.Update
  .Close
End With
Set stm = Nothing

End Sub

Random Solutions  
 
programming4us programming4us