Confused about MissingSchemaAction.AddWithKey

G

Guest

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();
}
 
N

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top