C# 질문을 여기다가해도 되는지 모르겠네요..
민아
C#으로 DB의 Insert 메소드를 만들고있는데요.
이렇게 만들면 ID 가 순서대로 숫자로 (1,2,3,4....) 입력이 되는데 제가 하고싶은건
A0001, A0002......B0001.....AA001 이렇게 하고싶은데
ExecuteNonQuery() 메소드를 오버라이드 할수 있나요?
제가 만든 코드로 바꿔서 쓰고싶습니다..
할 수 없다면 다르게 할 수 있는 방법 좀 알려주세요..ㅠㅠ 부탁드립니다
public string Insert(string sql)
{
string newID = ;
// Open a connection to the database.
string connectionString = getConnectionString();
OleDbConnection myConnection = new OleDbConnection(connectionString);
myConnection.Open();
// Run the command.
OleDbCommand myCommand = new OleDbCommand(sql, myConnection);
myCommand.ExecuteNonQuery();
// Create and run a new command to fetch the ID.
myCommand = new OleDbCommand(SELECT @@Identity, myConnection);
newID = (string)myCommand.ExecuteScalar();
// Make sure to close the connection
myConnection.Close();
return newID;
}