solution1368
asked on
c#, asp.net
The attached code is working. However, we won't know how rows will be returned into
string[] x = new string[?].
For now, I hard code to 3. How can I handle the code without knowing the number of rows in a array?
a.txt
string[] x = new string[?].
For now, I hard code to 3. How can I handle the code without knowing the number of rows in a array?
a.txt
ASKER
can you change the codes based on my codes? and more importantly, how to call the function in the front end?
At Top Of Code File
Front End
using System.Collections.Generic;
public string[] GetBondViewList(string stateCode, string classSubCodeName, int statusID)
{
DbCommand com = GenericDataAccess.CreateCommand();
com.CommandText = "GetBondViewUI";
DbParameter param = com.CreateParameter();
//==============================================
param.ParameterName = "@StateCode";
param.Value = stateCode;
param.DbType = DbType.String;
com.Parameters.Add(param);
//===============================================
param = com.CreateParameter();
param.ParameterName = "@classSubCodeName";
param.Value = classSubCodeName;
param.DbType = DbType.String;
com.Parameters.Add(param);
//===============================================
param = com.CreateParameter();
param.ParameterName = "@StatusID";
param.Value = 1;
param.DbType = DbType.Int16;
com.Parameters.Add(param);
//===============================================
DataTable dt = GenericDataAccess.ExecuteSelectCommand(com);
if (dt.Rows.Count > 0)
{
List<string> y = new List<string>();
for (int i = 0; i < dt.Rows.Count; i++)
{
y.Add(dt.Rows[i]["ViewName"].ToString());
}
return y.ToArray();
}
else
{
return null;
}
}
}
Front End
string[] result = GetBondViewList("some code", string "some sub code", 1);
ASKER
frontend. it is string array. like string[0] = something1 string[1] = something2...how to do that?
I do not understand the question.
ASKER
string[] result = GetBondViewList("some code", string "some sub code", 1);
how to call them in an array?
how to call them in an array?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. this for loop is working okay.
e.g.
Open in new window