I was wondering if anyone could tell me why my code is not displaying anything. My connection is correct because I did copy it from a program that already works properly. *Beginner Student*
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.Data.SqlClient.SqlConnection myConnection = new System.Data.SqlClient.SqlConnection("user id=sa;" +
"password=JFK9j0b;server=RPLSQL;" +
"Trusted_Connection=yes;" +
"database=TDSSW; " +
"connection timeout=30000");
try
{
myConnection.Open();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
try
{
System.Data.SqlClient.SqlDataReader myReader = null;
System.Data.SqlClient.SqlCommand myCommand = new System.Data.SqlClient.SqlCommand("select itemid from laitem",
myConnection);
myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
Console.WriteLine(myReader["ItemId"].ToString());
// Console.WriteLine(myReader["Column2"].ToString());
Console.ReadLine();
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}