Welcome to dbFreaks.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Passing Var's to Procedure

 
   Database Help (Home) -> Visual Basic RSS
Next:  Expanation?  
Author Message
Ben82

External


Since: Sep 16, 2004
Posts: 12



(Msg. 1) Posted: Sat Feb 12, 2005 4:53 am
Post subject: Passing Var's to Procedure
Archived from groups: microsoft>public>vb>database (more info?)

what should I change in the procedure below that I can call it with more
variables...(i,e)
File2SqlBlob("c:\pic1.jpg","tablename","colname")
I am having problem defining the variables within the procedure ..thank you
for help



Private Sub File2SqlBlob(ByVal SourceFilePath As String)
Dim cn As New SqlConnection("server=localhost;integrated
security=yes;database=NorthWind")
Dim cmd As New SqlCommand("UPDATE Categories SET Picture=@Picture WHERE
CategoryName='Test'", cn)
Dim fs As New System.IO.FileStream(SourceFilePath, IO.FileMode.Open,
IO.FileAccess.Read)
Dim b(fs.Length() - 1) As Byte
fs.Read(b, 0, b.Length)
fs.Close()
Dim P As New SqlParameter("@Picture", SqlDbType.Image, b.Length,
ParameterDirection.Input, False, 0, 0, Nothing, DataRowVersion.Current, b)
cmd.Parameters.Add(P)
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
End Sub

 >> Stay informed about: Passing Var's to Procedure 
Back to top
Login to vote
Douglas J. Steele

External


Since: Mar 14, 2004
Posts: 1616



(Msg. 2) Posted: Sat Feb 12, 2005 8:35 am
Post subject: Re: Passing Var's to Procedure [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

WIthout knowing how tablename and colname are to be used in your procedure,
it's difficult to say.

However, your code appears to be VB.Net, and this newsgroup is intend for
questions related to "ClassicVB" only (VB6 and earlier). The .Net groups all
have dotnet in their names.


--
Doug Steele, Microsoft Access MVP
<a style='text-decoration: underline;' href="http://I.Am/DougSteele" target="_blank">http://I.Am/DougSteele</a>
(no e-mails, please!)



"Ben" <Ben.RemoveThis@discussions.microsoft.com> wrote in message
news:38BF7B9F-D64E-4444-8DA8-D29264D03174@microsoft.com...
 > what should I change in the procedure below that I can call it with more
 > variables...(i,e)
 > File2SqlBlob("c:\pic1.jpg","tablename","colname")
 > I am having problem defining the variables within the procedure ..thank
 > you
 > for help
 >
 >
 >
 > Private Sub File2SqlBlob(ByVal SourceFilePath As String)
 > Dim cn As New SqlConnection("server=localhost;integrated
 > security=yes;database=NorthWind")
 > Dim cmd As New SqlCommand("UPDATE Categories SET Picture=@Picture WHERE
 > CategoryName='Test'", cn)
 > Dim fs As New System.IO.FileStream(SourceFilePath, IO.FileMode.Open,
 > IO.FileAccess.Read)
 > Dim b(fs.Length() - 1) As Byte
 > fs.Read(b, 0, b.Length)
 > fs.Close()
 > Dim P As New SqlParameter("@Picture", SqlDbType.Image, b.Length,
 > ParameterDirection.Input, False, 0, 0, Nothing, DataRowVersion.Current, b)
 > cmd.Parameters.Add(P)
 > cn.Open()
 > cmd.ExecuteNonQuery()
 > cn.Close()
 > End Sub
 >
 >
 ><!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: Passing Var's to Procedure 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> Visual Basic All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]