I am currently facing a problem here. I have a column called "DESC1" in a table called "Master". I'm trying to retrieve the value based on something along the lines of this...
"Select DESC1 FROM Master WHERE '" & TextBox1.Text & "' "
And I'm trying to display on the excel beside both correctString1 and correctString
oWB.Sheets(1).Range("E2").Value = " " & correctString1 & " : " & correctString & " "
Hope you guys can help me out. Thanks!
Best How To :
Dim sqlConnection1 As New SqlConnection("Your Connection String")
Dim cmd As New SqlCommand
Dim reader As SqlDataReader
cmd.CommandText = "Select DESC1 FROM Master WHERE '" & TextBox1.Text & "' "
cmd.CommandType = CommandType.Text
cmd.Connection = sqlConnection1
reader = cmd.ExecuteReader()
' Data is accessible through the DataReader object here.
If reader.HasRows Then
Do While reader.Read()
& vbTab & reader.GetString(1))
Console.WriteLine("No rows found.")
Considering first column is
NUMBER type and second column is
connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"