You can do this using the below code;
Dim cnn As SqlConnection
Dim connectionString As String
Dim sql As String
connectionString = "data source=[servername];initial catalog=[databasename];user id=[username];password=[password];"
cnn = New SqlConnection(connectionString)
cnn.Open()
Dim sqlString as String
sqlString = "Select * From Table1 Where ID = " & txtID.Text
Dim dscmd As New SqlDataAdapter(sqlString, cnn)
Dim ds As New DataSet1
dscmd.Fill(ds, "Table1")
objRpt.SetDataSource(ds.Tables(1))
CrystalReportViewer1.ReportSource = objRpt
CrystalReportViewer1.Refresh()
Hope this helps... :)
Jasmin