Results 1 to 4 of 4

Thread: Need help with database stuff! **SOLVED**

  1. #1

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Unhappy Need help with database stuff! **SOLVED**

    Hey its me ..... again.......

    Ok here we go,
    all I want is one String value returned from my Database. (SQLSERVER). Here is my code with what I do up till now:

    Code:
    			string sConn = "server=local;Trusted_Connection=yes;database=InternalIdTracking";
    			string command = "UPDATE Tracking SET status ='" +type_number +"' WHERE( mappedId LIKE '"+localid + "')" ;
    			 
    			SqlConnection conn = new SqlConnection(sConn);
    			conn.Open();
    			SqlCommand execute = new SqlCommand(command,conn);
    			execute.ExecuteNonQuery();
    			
    			command = "SELECT internalId FROM Tracking Where (mappedId LIKE '"+localid+"')";
    			SqlCommand selectId	 = new SqlCommand(command,conn);
    			string selectedid = selectId.ExecuteNonQuery().ToString(); //this is not working 
    			
    			conn.Close();
    
    
    
    			return "selectedid";
    Thanx,
    Stephan
    Last edited by Sgt-Peppa; Jul 25th, 2003 at 03:34 AM.
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  2. #2

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    PLEASE, need some help here!

    Ok lets not get to difficult on this one. How can I read Data from my Database using a SQL Statement and convert it to a string?

    With my posted code above I only get a -1 !

    Please gimme a hand on this one

    Thanx Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  3. #3

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    UPDATE Ok i found out that dataset stuff, but how can I get a value out of that dataset thingy?

    heres my code:

    Code:
    command = "SELECT internalId FROM Tracking Where (mappedId LIKE '"+localid+"')";
    SqlCommand selectId	 = new SqlCommand(command,conn);
    string selectedid = "";
    
    System.Data.DataSet rs = new DataSet("internalId"); 
    
    SqlDataAdapter daad = new SqlDataAdapter(command,conn);
    daad.TableMappings.Add("Table","internalId");
    daad.Fill(rs);
    
    selectedid = rs.Tables["internalId"].Columns["internalId"].;
    selectedid = rs.Tables["internalId"].Rows[0].ToString();
    			
    conn.Close();
    Thanx, Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  4. #4

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    Ok I solved this using a DataReader!

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width