This is a multi-part message in MIME format.
------=_NextPart_000_0049_01C5052D.3F21E3E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
I use OleDbCommand to insert a new row to Access database. We reuse =
instance of OleDbCommand more than one times.=20
=20
example:
- The value of the first record is QueryID =3D 1 and =
BooleanOperator =3D "And"; Add to database correctly;
- The value of the second record is QueryID =3D 1 and =
BooleanOperator =3D "Or"; Add to database not correctly;
=20
Here is the value in database:
QueryID BooleanOperator
1 And
1 Ord =20
=20
The value of BooleanOperator is "Ord". Could you tell me how to =
solve this problem, please?
Here is the code:
OleDbCommand cmdClause =3D new OleDbCommand();
cmdClause.CommandType =3D CommandType.StoredProcedure;
cmdClause.CommandText =3D SP_QUERY_SAVEQUERYCLAUSE;
=20
cmdClause.Parameters.Add( "@QueryId", OleDbType.Integer);
cmdClause.Parameters.Add( "@BooleanOperator", OleDbType.VarWChar, =
50);
using (OleDbConnection cn =3D new =
OleDbConnection(this.ConnectionString)) {
cn.Open();
cmdClause.Connection =3D cn;
foreach (QueryClause clause in queryClauses) {
cmdClause.Parameters["@QueryId"].Value =3D queryId;
cmdClause.Parameters["@BooleanOperator"].Value =3D =
clause.BooleanOperator;
=20
cmdClause.ExecuteNonQuery();
}
}
Thanks,
Hung
------=_NextPart_000_0049_01C5052D.3F21E3E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1479" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> I use OleDbCommand =
to insert a=20
new row to Access database. We reuse instance of=20
OleDbCommand more than one times. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2> </FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
example:</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> -=20
The value of the first record is <FONT color=3D#0080ff>QueryID =3D =
1</FONT> =20
and <FONT color=3D#0080ff>BooleanOperator =3D "And"</FONT>; Add=20
to database correctly;</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> -=20
The value of the second record is <FONT color=3D#0080ff>QueryID =3D =
1</FONT> and=20
<FONT color=3D#0080ff>BooleanOperator =3D "Or"</FONT>; Add to database =
not=20
correctly;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> </FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> Here is=20
the value in database:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
QueryID BooleanOperator</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
1 =
=20
And</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> 1 &nb=
sp;=20
Or<FONT=20
color=3D#ff0000>d</FONT> </FONT></DIV>
<DIV><FONT face=3DArial size=3D2> </FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2> The=20
value of BooleanOperator is "<FONT color=3D#ff0000>Ord</FONT>". Could =
you tell me=20
how to solve this problem, please?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> Here is the =
code:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> OleDbCommand =
cmdClause =3D=20
new OleDbCommand();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> =
cmdClause.CommandType =3D=20
CommandType.StoredProcedure;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
cmdClause.CommandText =3D=20
SP_QUERY_SAVEQUERYCLAUSE;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> </FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
cmdClause.Parameters.Add(=20
"@QueryId", OleDbType.Integer);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
cmdClause.Parameters.Add(=20
"@BooleanOperator", OleDbType.VarWChar, 50);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> using =
(OleDbConnection cn =3D new=20
OleDbConnection(this.ConnectionString)) {</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p; =20
cn.Open();</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p; cmdClause.Connection=20
=3D=20
cn;<BR> =
=20
foreach (QueryClause clause in queryClauses)=20
{<BR> &n=
bsp; =20
cmdClause.Parameters["@QueryId"].Value =3D=20
queryId;<BR> &=
nbsp; =20
cmdClause.Parameters["@BooleanOperator"].Value =3D=20
clause.BooleanOperator;</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p; =20
</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p; =20
cmdClause.ExecuteNonQuery();</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p; =20
}</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p;=20
}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Hung</FONT></DIV></BODY></HTML>
------=_NextPart_000_0049_01C5052D.3F21E3E0--