我有一个 WinForm,
我已经添加了命令行功能 -
foreach (string arg in args)
{
if (arg == "-id")
{
string u = "";
ADODB.Connection ADconn = new ADODB.Connection();
string connstr = "db connection string";
ADconn.ConnectionString = connstr;
object recs;
ADODB.Recordset rs = new ADODB.Recordset();
ADconn.Open(connstr);
string qry = string.Format("Select ID from TABLE where NO = '" + args[counts + 1] + "'");
rs = ADconn.Execute(qry, out recs, 0);
for (; !rs.EOF; rs.MoveNext())
{
string test = rs.Fields["column"].Value.ToString();
u = test;
}
}
counts = counts + 1;
}
因此args[counts + 1]
,用户在命令行中输入的任何变量都是-id
. 我需要稍后在我的代码中使用这个值但是我该怎么做呢?