obtener valor de la fuente de datos del objeto

this is a part of my Stored Procedure :

Create procedure sp_Units_GetUnitState  
@PadidehOrAtkinsCode int  
as
    Select State from Units where ID = @PadidehOrAtkinsCode  
go  

I have a DataSet (.XSD) file which has my StoredProcedure (named GetDataBy1 here)
enter image description here
I pass the parameter like this :

odsUnit.SelectParameters["PadidehOrAtkinsCode"].DefaultValue =  
txtPadidehOrAtkinsCode.Text;  

Now I want to fill my textbox Text property with the State field I had in my stored procedure, what should I do to get the value from osdUnit?
enter image description here

preguntado el 31 de julio de 12 a las 12:07

comprueba mi respuesta, funcionará. -

1 Respuestas

Create an object of your stored procedure and call the GetData function. No need to assign select parameters to your objectdatasource. Follow below example: I assumed your dataset name is dataset1.

DataTable dt1 = new DataTable();  // for temporary storage
DataSet1TableAdapters.sp_Units_GetUnitState  objAda = new DataSet1TableAdapters.sp_Units_GetUnitState();
dt1 = objAda.GetData(txtPadidehOrAtkinsCode.Text);

// Now get the state from the datatable
string state = dt1.Rows[0][0].ToString();

Respondido 31 Jul 12, 13:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.