Re: How to fill a dataset from an inline function ? by Mythran
Mythran
Fri Sep 03 15:06:16 CDT 2004
I'm not quite sure as I do not rely on udf's for anything. If I can't do it in a
sp or trigger, then I'm probably doing it wrong.
:P Just my way of doing it I guess.
Mythran
"Sarah" <Sarah@discussions.microsoft.com> wrote in message
news:E7C5C2B9-2266-4D5B-8EA8-C9C75E9E73CE@microsoft.com...
> Many thanks Mythran - sorry for late reply - was on hols.
>
> Your suggestion works, but the thing that confused me was I expected the
> Command.Type to be StoredProcedure and to set up parameters via sqlparameters
> object whereas you have used a text string and the default Command.Type=Text.
> Is there no support for treating udf's like stored procedures ?
>
> Thanks again
>
> Sarah
>
> "Mythran" wrote:
>
> >
> > "Sarah" <Sarah@discussions.microsoft.com> wrote in message
> > news:51CE4603-F57F-46A6-875E-F28C8C9D6F64@microsoft.com...
> > > Thanks for the reply Mythran but that's not quite the problem .... I
> > > understand the SQL parts its the VB end that I'm having probs with.
> > >
> > > I can call stored procedures with output parameters fine but can't figure
> > > out how to get the TABLE from the UDF. I cant seem to set up the right
> > > combination of dataadapter/commands etc to get it to work.
> > >
> > > Can anyone help ?
> >
> > Off top of my head...
> >
> > Dim ds As DataSet
> > Dim conn As SqlConnection
> > Dim cmd As SqlCommand
> > Dim adap As SqlDataAdapter
> >
> > conn = New SqlConnection("MyConnectionStringHere")
> >
> > Try
> > conn.Open()
> > cmd = New SqlCommand("SELECT * FROM :MyFunction", conn)
> > adap = New SqlDataAdapter(cmd)
> > ds = New DataSet()
> >
> > adap.Fill(ds, "tblMyFunction")
> > Finally
> > conn.Dispose()
> > End Try
> >
> > I believe this will work.
> >
> > Mythran
> >
> >
> >