Hello.Im a beginner in SQL.I am having a problem with it. First of all I shd let u know I installed SQL 2005 Server n then made a ConsoleApp and rest of code is under :
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
SqlConnection myConnection = new SqlConnection("user id=userid;" +
"Password=validpassword;" +
"Trusted_Connection=yes;" +
"Data Source=localhost;" +
"connection timeout=300");
try
{
myConnection.Open();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
SqlCommand myCommand = new SqlCommand("INSERT INTO table (Column1, Column2) " +
"Values ('string', 1)", myConnection);
myCommand.ExecuteNonQuery();
}
}
}
WHEN I RUN IT...I get An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll with myCommand.ExecuteNonQuery();
Kidnly guide me where Im going wrong.I just want to do simple stuff.Insert something n then read it.But I get error even at inserting.