if (bIsStoredProcedure)
sqlda.SelectCommand.CommandType = CommandType.StoredProcedure;
else
sqlda.SelectCommand.CommandType = CommandType.Text;
foreach (SqlParameter param in sqlParameters)
{
sqlda.SelectCommand.Parameters.Add(param);
}
return sqlda;
}
/// <summary>
/// Create SqlParameter[]
/// </summary>
/// <param></param>
/// <returns></returns>
public static SqlParameter[] CreateSqlParameters(object[,] sqlParameterArr)
{
SqlParameter[] sqlParameters = new SqlParameter[sqlParameterArr.GetLength(0)];
int i = 0;
foreach (SqlParameter param in sqlParameters)
{
sqlParameters[i] = new SqlParameter(Convert.ToString(sqlParameterArr[i, 0]), sqlParameterArr[i, 1]);
i++;
}
return sqlParameters;
}
/// <summary>
/// add Parameters for Command
/// </summary>
/// <param></param>
/// <param></param>
public static void AddCommandParams(ref SqlCommand sqlcmd, SqlParameter[] sqlParameters)
{
foreach (SqlParameter param in sqlParameters)
{
sqlcmd.Parameters.Add(param);
}
}
/// <summary>
/// add Parameters for DataAdapter
/// </summary>
/// <param></param>
/// <param></param>
public static void AddDataAdapterParam(ref SqlDataAdapter sqlda, SqlParameter[] sqlParameters)
{
foreach (SqlParameter param in sqlParameters)
{
sqlda.SelectCommand.Parameters.Add(param);
}
}
/// <summary>
/// Get SQLScript
/// </summary>
/// <param></param>
/// <param></param>
public static string GetSQLScript(string strFilepath,string strNodePath)
{
string strSql;
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(strFilepath);
XmlNode node = xmldoc.SelectSingleNode(strNodePath);
strSql = node.ChildNodes[0].InnerText;
return strSql;
}
}
#endregion
}