OdbcParameter.ParameterName 속성

정의

OdbcParameter의 이름을 가져오거나 설정합니다.

public:
 virtual property System::String ^ ParameterName { System::String ^ get(); void set(System::String ^ value); };
public:
 property System::String ^ ParameterName { System::String ^ get(); void set(System::String ^ value); };
public override string ParameterName { get; set; }
public string ParameterName { get; set; }
member this.ParameterName : string with get, set
Public Overrides Property ParameterName As String
Public Property ParameterName As String

속성 값

OdbcParameter의 이름입니다. 기본값은 빈 문자열("")입니다.

구현

예제

다음 예제에서는 데이터 원본에 테이블 이름 MyTable 과 로 정의된 MyProc이라는 저장 프로시저가 있다고 가정합니다.

CREATE TABLE MyTable (col1 int, col2 smallmoney, col3 decimal)  
CREATE PROC MyProc (@p1 int, @p2 smallmoney, @p3 decimal) AS INSERT INTO MyTable VALUES (@p1, @p2, @p3)  

다음 예제에서는 매개 변수를 만들고 MyProc 저장 프로시저를 호출합니다.

Public Sub CreateMyProc(connection As OdbcConnection)  

   Dim command As OdbcCommand = connection.CreateCommand()  

   command.CommandText = "{ call MyProc(?,?,?) }"  
   command.Parameters.Add("", OdbcType.Int).Value = 1  
   command.Parameters.Add("", OdbcType.Decimal).Value = 2  
   command.Parameters.Add("", OdbcType.Decimal).Value = 3  

End Sub  
public void CreateMyProc(OdbcConnection connection)   
{  
   OdbcCommand command = myConnection.CreateCommand();  

   command.CommandText = "{ call MyProc(?,?,?) }";  
   command.Parameters.Add("", OdbcType.Int).Value = 1;  
   command.Parameters.Add("", OdbcType.Decimal).Value = 2;  
   command.Parameters.Add("", OdbcType.Decimal).Value = 3;  
}  

설명

ODBC .NET 공급자는 명명된 매개 변수 대신 명령 텍스트 구문에 물음표(?)로 표시된 위치 매개 변수를 사용합니다. 의 OdbcParameterCollection 매개 변수 개체 및 저장 프로시저 또는 매개 변수가 있는 SQL 문에서 수락한 실제 매개 변수는 개체가 매개 변수 이름 대신 컬렉션에 삽입되는 OdbcParameter 순서에 따라 서로 일치합니다. 매개 변수 이름을 제공할 수 있지만 매개 변수 개체 바인딩 중에는 무시됩니다.

적용 대상

추가 정보