Can someone please tell me why the results of my query are not appearing in my console application? I have a feeling it is something wrong with the console.writeline or readline
Imports System.Data
Imports System.Data.SqlClient
Module Module1
Private Property Sql As String
Sub Main()
Dim ConnString As String = "Data Source=10.5.1.9;Initial Catalog=AddressStagingTable;Persist Security Info=True;User ID=sa;Password=JFK9j0b"
Using Con As New SqlConnection(ConnString)
Con.Open()
Sql = "Insert into Address(streetname) values(@streetname)"
Dim cmd1 As New SqlCommand(Sql, Con)
cmd1.Parameters.Add("@streetname", SqlDbType.VarChar, 22)
cmd1.Parameters("@streetname").Value = "KENTUCKY ST N"
cmd1.ExecuteNonQuery()
'Insert New Record
cmd1.Parameters("@streetname").Value = "SMITH ST N"
cmd1.ExecuteNonQuery()
'Read Records
Sql = "select * from address where itemtype = 'R2' "
Dim cmd As New SqlCommand(Sql, Con)
Console.WriteLine(cmd.ExecuteScalar())
Console.ReadLine()
End Using
End Sub
End Module