c# - Select sql how to get value DataReader -
I want to get value / mages / again, but how do I work it. For example, please show me how the selection of the value defines how the variable is shown or how it is shown in the text box.
At this point I get "System.Data.SqlClient.SqlDataReader" in the textbox.
SqlDataReader Reader; Cn.Open (); Cmd.CommandText = ("Select Megaeska for Orty Wear Orty. Id =" Reservoir "); Cmd.Parameters.AddWithValue ("@Rezwayway", RISSEVA); Cmd.CommandType = CommandType.Text; CMD Connection = CN; Reader = CMD.x Reader (). String RS = Convert. ToString (Reader); TextBox1.Text = rs; // At this point I get the "System.Data.SqlClient.SqlDataReader" text box in cn.Close ();
If you are reading a row and a single column: simply ExecuteScalar ( ) : string rs = (string) cmd.ExecuteScalar (); But to answer your question, the common use is:
using (var reader = cmd.ExecuteReader ()) {while ( Reader.Read ()) {// Read a line, for example: string foo = reader.GetString (0); Console.WriteLine (foo); }}
Comments
Post a Comment