Home All Groups Group Topic Archive Search About

Confused about MissingSchemaAction.AddWithKey

Author
28 Jan 2005 5:29 PM
Tony

Hi!
I am trying to improve the speed of the app. Can you tell me if i need to
use AddWithKey or not? Thanks.


if (base.OpenDB() != System.Data.ConnectionState.Open) { throw new
Exception("Unable to open DB connection!"); }
string sSQL = "SELECT * FROM PROCESSCONTROLVIEW WHERE GROUP_ID = '" + sTemp
+ "'";
da = new SqlDataAdapter(sSQL, base.Connection);
ds = new System.Data.DataSet();
cb = new SqlCommandBuilder(da);
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
da.Fill(ds, "PROCESSCONTROLVIEW");
if (ds.Tables["PROCESSCONTROLVIEW"].Rows.Count != 1)
return new VCDI();
try
{
cdi.Head.PressNum =
ds.Tables["PROCESSCONTROLVIEW"].Rows[0]["PRESS_NUM"].ToString().ToCharArray();
}
catch (Exception)
{
cdi.Head.PressNum[0] = '\x30';
cdi.Head.PressNum[1] = '\0';
}
try
{
cdi.Head.LayNum =
ds.Tables["PROCESSCONTROLVIEW"].Rows[0]["LAY_NUM"].ToString().ToCharArray();
}
catch (Exception)
{
cdi.Head.LayNum[0] = '\x30';
cdi.Head.LayNum[1] = '\0';
}
try
{
cdi.Head.ReadTime =
DateTime.Parse(ds.Tables["PROCESSCONTROLVIEW"].Rows[0]["READDATE"].ToString());
}
catch (Exception)
{
cdi.Head.ReadTime = DateTime.Now;
}
try
{
cdi.Head.ReaderNumber =
ds.Tables["PROCESSCONTROLVIEW"].Rows[0]["READER_NUM"].ToString().ToCharArray();
}
catch (Exception)
{
cdi.Head.ReaderNumber = "0".ToCharArray();
}
Author
28 Jan 2005 6:50 PM
NuTcAsE
AddWithKey will specify the adapter to also retreive the table schema
and identify the primary keys in the table. Looking at your code i dont
think you need to specify AddWithKey since you are not doing any
specific processing based on the primary key of the table.

Bookmark and Share