[dba-VB] Connecting to SQL Database

David Emerson newsgrps at dalyn.co.nz
Thu Jun 7 01:59:58 CDT 2007


Thanks Mark,  That worked just fine.

David

At 7/06/2007, you wrote:
>One way to go is to use a data reader to get the values. Declare your
>variables, and then fill them with the values from the SQLDataReader:
>
>Dim strReportName  as String
>Dim intParType as Integer
>
>
>
> >              Dim conn As New SqlConnection
> >              conn.ConnectionString = "data source=DALYN;initial
> > catalog=MLV;integrated security=SSPI;persist security info=False"
> >              Dim Cmd = New SqlClient.SqlCommand("SELECT ReportName,
> > ParType from tblReports where ReportID = @ReportID", conn)
> >              Cmd.CommandType = CommandType.Text
> >              Cmd.Parameters.Add("@ReportID", intReport)
> >              conn.Open()
>Dim ReportReader as SqlDataReader = Cmd.ExecuteReader()
>ReportReader.Read
>strReportName  = ReportReader.GetValue(0)
>intParType = ReportReader.GetValue(1)
>conn.Close
>
>HTH!
>--
>Mark Rider
>http://dfwmdug.org
>
>Don't anthropomorphize computers.
>They don't like it.
>_______________________________________________
>dba-VB mailing list
>dba-VB at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-vb
>http://www.databaseadvisors.com




More information about the dba-VB mailing list