SQL에서 초보자가되었습니다. 문제가 있습니다. 내가 IT를 실행할 때 ... 나는 유형의 처리되지 않은 예외를 얻을기본 SQL 항목에 문제가 있습니다.
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();
}
}
}
'시스템 : 내가 할 수 SHD 모든 먼저 u는 내가 SQL 2005 서버를 설치 한 N 다음 ConsoleApp을 만들어 아래 코드의 나머지는 알고있다 .Data.SqlClient.SqlException 'System.Data.dll에서 발생했습니다. with myCommand.ExecuteNonQuery();
내가 잘못 가고있는 곳을 안내해줍니다. 간단한 일을하고 싶습니다. 뭔가를 삽입 한 다음 읽습니다.하지만 삽입하는 중에도 오류가 발생합니다.
연결이 열려 있습니까? –
테이블이 이미 생성 되었습니까? –