adding data

Discussion in 'ASP .Net' started by Selen, Mar 2, 2004.

  1. Selen

    Selen Guest

    Hello,
    I add my data from sqlserver to dropdownlist on formload.I wanted it doesnt
    load data every time on form load.I made if session is null then load if
    session isnt null dont load.I add to sqlserver a new data ans I make session
    is null.But in dropdownlist I coudnt see my new data.I use below code for
    adding.I make logic error. Is Using Session logic true? or I have to refresh
    sql data if so how can I do this...
    SqlConnection conn=new SqlConnection ();

    conn.ConnectionString
    ="server=(local)\\sql2000;database=db_Kalite_Data;uid=sa;pwd=antalya";

    SqlCommand cmd=new SqlCommand ();

    cmd.Connection =conn;

    string str="insert ........................";

    cmd.CommandText =str;

    conn.Open ();

    cmd.ExecuteNonQuery ();

    conn.Close ();

    Thanks...
     
    Selen, Mar 2, 2004
    #1
    1. Advertising

  2. Selen

    Simon Gorski Guest

    Hello Selen,
    "Selen" <> schrieb im Newsbeitrag
    news:...
    > Hello,
    > I add my data from sqlserver to dropdownlist on formload.I wanted it

    doesnt
    > load data every time on form load.I made if session is null then load if
    > session isnt null dont load.I add to sqlserver a new data ans I make

    session
    > is null.But in dropdownlist I coudnt see my new data.I use below code for
    > adding.I make logic error. Is Using Session logic true? or I have to

    refresh
    > sql data if so how can I do this...
    > SqlConnection conn=new SqlConnection ();
    >
    > conn.ConnectionString
    > ="server=(local)\\sql2000;database=db_Kalite_Data;uid=sa;pwd=antalya";
    >
    > SqlCommand cmd=new SqlCommand ();
    >
    > cmd.Connection =conn;
    >
    > string str="insert ........................";
    >
    > cmd.CommandText =str;
    >
    > conn.Open ();
    >
    > cmd.ExecuteNonQuery ();
    >
    > conn.Close ();
    >
    > Thanks...


    I think the problem is, that you must re-bind the dropdownlist after
    refreshing the data!

    mfg simon g.
     
    Simon Gorski, Mar 2, 2004
    #2
    1. Advertising

  3. Selen

    Selen Guest

    sorry What you mean re-bind??

    Thank you...

    "Simon Gorski >" <<>, iletide þunu yazdý
    news:...
    > Hello Selen,
    > "Selen" <> schrieb im Newsbeitrag
    > news:...
    > > Hello,
    > > I add my data from sqlserver to dropdownlist on formload.I wanted it

    > doesnt
    > > load data every time on form load.I made if session is null then load

    if
    > > session isnt null dont load.I add to sqlserver a new data ans I make

    > session
    > > is null.But in dropdownlist I coudnt see my new data.I use below code

    for
    > > adding.I make logic error. Is Using Session logic true? or I have to

    > refresh
    > > sql data if so how can I do this...
    > > SqlConnection conn=new SqlConnection ();
    > >
    > > conn.ConnectionString
    > > ="server=(local)\\sql2000;database=db_Kalite_Data;uid=sa;pwd=antalya";
    > >
    > > SqlCommand cmd=new SqlCommand ();
    > >
    > > cmd.Connection =conn;
    > >
    > > string str="insert ........................";
    > >
    > > cmd.CommandText =str;
    > >
    > > conn.Open ();
    > >
    > > cmd.ExecuteNonQuery ();
    > >
    > > conn.Close ();
    > >
    > > Thanks...

    >
    > I think the problem is, that you must re-bind the dropdownlist after
    > refreshing the data!
    >
    > mfg simon g.
    >
    >
     
    Selen, Mar 2, 2004
    #3
  4. Selen

    Simon Gorski Guest

    Hello Selen,
    "Selen" <> schrieb im Newsbeitrag
    news:%...
    > sorry What you mean re-bind??
    >
    > Thank you...
    >
    > "Simon Gorski >" <<>, iletide þunu yazdý
    > news:...
    > > Hello Selen,
    > > "Selen" <> schrieb im Newsbeitrag
    > > news:...
    > > > Hello,
    > > > I add my data from sqlserver to dropdownlist on formload.I wanted it

    > > doesnt
    > > > load data every time on form load.I made if session is null then load

    > if
    > > > session isnt null dont load.I add to sqlserver a new data ans I make

    > > session
    > > > is null.But in dropdownlist I coudnt see my new data.I use below code

    > for
    > > > adding.I make logic error. Is Using Session logic true? or I have to

    > > refresh
    > > > sql data if so how can I do this...
    > > > SqlConnection conn=new SqlConnection ();
    > > >
    > > > conn.ConnectionString
    > > > ="server=(local)\\sql2000;database=db_Kalite_Data;uid=sa;pwd=antalya";
    > > >
    > > > SqlCommand cmd=new SqlCommand ();
    > > >
    > > > cmd.Connection =conn;
    > > >
    > > > string str="insert ........................";
    > > >
    > > > cmd.CommandText =str;
    > > >
    > > > conn.Open ();
    > > >
    > > > cmd.ExecuteNonQuery ();
    > > >
    > > > conn.Close ();
    > > >
    > > > Thanks...

    > >
    > > I think the problem is, that you must re-bind the dropdownlist after
    > > refreshing the data!


    DropDownList myList = new DropDownList();

    myList.Add("newItem1");

    myList.Add("newItem2");

    myList.DataBind(); <--

    After you refreshed your data, you have to make a re-bind -->
    myList.DataBind();

    mfg simon g.
     
    Simon Gorski, Mar 2, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. george d lake
    Replies:
    0
    Views:
    505
    george d lake
    Aug 29, 2003
  2. Kimberly Walker

    Dropdownlist adding data after databind

    Kimberly Walker, Oct 23, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    474
    Kimberly Walker
    Oct 23, 2003
  3. Robin Thomas
    Replies:
    3
    Views:
    395
    vMike
    Jan 19, 2004
  4. Paul Smith

    Adding Data To Data Base

    Paul Smith, Aug 26, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    400
    John Rivers
    Aug 30, 2005
  5. Neo Geshel
    Replies:
    2
    Views:
    759
    Neo Geshel
    Nov 17, 2005
Loading...

Share This Page