Question about IDataParameterCollection

J

jiangyh

hi there:

I have a class inplement IDataParameterCollection.looks like buttom code,I have a override method named this.

public class DBParameters : ArrayList, IDataParameterCollection
{
public object this[string parameterName]
{
get
{
return this.IndexOf(parameterName);
}
set
{
// TODO: Add DBParameters.this setter implementation
}
}
}


I have another method in another class like buttom.

public void GetCommand(IDbCommand cmd, string strCmdText, CommandType cmdType, DBParameters parameterCollection)
{
DBParameter objDbParameter;

for (int i = 0; i < parameterCollection.Count - 1; i++)
{
objDbParameter = parameterCollection;
cmd.Parameters.Add
(new SqlParameter(
objDbParameter.ParameterName,
objDbParameter.DbType,
objDbParameter.Size,
objDbParameter.SourceColumn));
}

}

I want (this) method return a DBParameter type object ,how can i achieve this .

thanks a lot
jiangyh
 
R

Richard Blewett [DevelopMentor]

What does a DBParameter type look like, how it is related to SqlParameter?

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

hi there: I have a class inplement IDataParameterCollection.looks like buttom code,I have a override method named this. public class DBParameters : ArrayList, IDataParameterCollection
{ public object this[string parameterName]
{
get
{
return this.IndexOf(parameterName);
}
set
{
// TODO: Add DBParameters.this setter implementation
}
} } I have another method in another class like buttom. public void GetCommand(IDbCommand cmd, string strCmdText, CommandType cmdType, DBParameters parameterCollection)
{
DBParameter objDbParameter;

for (int i = 0; i < parameterCollection.Count - 1; i++)
{
objDbParameter = parameterCollection;
cmd.Parameters.Add
(new SqlParameter(
objDbParameter.ParameterName,
objDbParameter.DbType,
objDbParameter.Size,
objDbParameter.SourceColumn));
} } I want (this) method return a DBParameter type object ,how can i achieve this . thanks a lot jiangyh
 
J

jiangyh

hi Richard Blewet:

First thanks you help ,DBParameter type is a member of collection that
type is DBParameters.

them related looks like SqlParameter and SqlParameterCollection

This is a define of DBParameter at buttom.
public class DBParameter : ArrayList, IDbDataParameter




Richard Blewett said:
What does a DBParameter type look like, how it is related to SqlParameter?

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

hi there: I have a class inplement IDataParameterCollection.looks
like buttom code,I have a override method named this. public class
DBParameters : ArrayList, IDataParameterCollection
{ public object this[string parameterName]
{
get
{
return this.IndexOf(parameterName);
}
set
{
// TODO: Add DBParameters.this setter implementation
}
} } I have another method in another class like buttom. public
void GetCommand(IDbCommand cmd, string strCmdText, CommandType cmdType,
DBParameters parameterCollection)
{
DBParameter objDbParameter;

for (int i = 0; i < parameterCollection.Count - 1; i++)
{
objDbParameter = parameterCollection;
cmd.Parameters.Add
(new SqlParameter(
objDbParameter.ParameterName,
objDbParameter.DbType,
objDbParameter.Size,
objDbParameter.SourceColumn));
} } I want (this) method return a DBParameter type object ,how

can i achieve this . thanks a lot jiangyh
 
R

Richard Blewett [DevelopMentor]

Ahh, I see whats happening now, I misread you GetCommand method.

change the indexer as follows:

DBParameters : ArrayList, IDataParameterCollection
{ public DBParameter this[string parameterName]
{
get
{
return (DBParameter)this.IndexOf(parameterName);
}
set
{
// TODO: Add DBParameters.this setter implementation
}
}
}

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

hi Richard Blewet:

First thanks you help ,DBParameter type is a member of collection that
type is DBParameters.

them related looks like SqlParameter and SqlParameterCollection
 
Top