SqlParameter and Generic array list
-
Hi all, For adding the data in database i m using SqlParameter array collection. In this method i am declering hardcoded array decleration of sqlparameter. Follwing the the example. public int Checkadmin(string usernm, string pwd) { SqlParameter[] sqlParam = new SqlParameter[2]; SqlDataReader dr; int count = 0; sqlParam[0] = new SqlParameter("@Username", SqlDbType.VarChar); sqlParam[0].Value = usernm; sqlParam[0].Size = 50; sqlParam[1] = new SqlParameter("@Password", SqlDbType.VarChar); sqlParam[1].Value = pwd; sqlParam[1].Size = 50; initializeDBConnection(); try { dr = execSelectByKeyParams("select.admin_login", sqlParam); while (dr.Read()) { count = Convert.ToInt32(dr.GetValue(0)); } } catch (SqlException sqlEx) { string str; str = sqlEx.Message + sqlEx.StackTrace; } catch (Exception ex) { string str; str = ex.Message + ex.StackTrace; } dispose(); return count; } Now i want to replace the SqlParameter array by generic arraylist.I dont want to user hardcoded array decleration. I have created sqlparameter generic arraylist as follow. List<SqlParameter[]> sqlParam=new List<SqlParameter[]>(); But can anybody guide me how can i proceed further. Thanks
People Laugh on me Because i am Different but i Laugh on them Because they all are same.
-
Hi all, For adding the data in database i m using SqlParameter array collection. In this method i am declering hardcoded array decleration of sqlparameter. Follwing the the example. public int Checkadmin(string usernm, string pwd) { SqlParameter[] sqlParam = new SqlParameter[2]; SqlDataReader dr; int count = 0; sqlParam[0] = new SqlParameter("@Username", SqlDbType.VarChar); sqlParam[0].Value = usernm; sqlParam[0].Size = 50; sqlParam[1] = new SqlParameter("@Password", SqlDbType.VarChar); sqlParam[1].Value = pwd; sqlParam[1].Size = 50; initializeDBConnection(); try { dr = execSelectByKeyParams("select.admin_login", sqlParam); while (dr.Read()) { count = Convert.ToInt32(dr.GetValue(0)); } } catch (SqlException sqlEx) { string str; str = sqlEx.Message + sqlEx.StackTrace; } catch (Exception ex) { string str; str = ex.Message + ex.StackTrace; } dispose(); return count; } Now i want to replace the SqlParameter array by generic arraylist.I dont want to user hardcoded array decleration. I have created sqlparameter generic arraylist as follow. List<SqlParameter[]> sqlParam=new List<SqlParameter[]>(); But can anybody guide me how can i proceed further. Thanks
People Laugh on me Because i am Different but i Laugh on them Because they all are same.