[dba-VB] Connecting to SQL Database

Mark Rider ridermark at gmail.com
Wed Jun 6 23:28:57 CDT 2007


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.



More information about the dba-VB mailing list