Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. SqlParameter and Generic array list

SqlParameter and Generic array list

Scheduled Pinned Locked Moved ASP.NET
tutorialdatabasedata-structuresquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rahul net11
    wrote on last edited by
    #1

    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.

    M 1 Reply Last reply
    0
    • R rahul net11

      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.

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      This [^]should help you.

      Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups