problem with data processing OracleDataReader (OracleRefCursor)





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















i need help, when i get the data of procedure BD (Oracle). I do not know how to deal with data type date time, int etc. I only know do with strings



public static Player_E getPlayer(string select)
{
Player_E player = new Player_E();
DateTime? dateTime = new DateTime();

conexion = bd.ConexionWithDB();

orden.CommandText = "CONSULTAS.obtener_jugador";
orden.CommandType = CommandType.StoredProcedure;
orden.Parameters.Add("v_nombre", OracleDbType.Varchar2, 60).Value = select;
orden.Parameters.Add("jugadores_dev", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output);


orden.Parameters.Add("c2blob", OracleDbType.Blob).Direction = ParameterDirection.Output;
orden.Connection = conexion;

orden.ExecuteNonQuery();

OracleDataReader dr = ((OracleRefCursor)orden.Parameters["jugadores_dev"].Value).GetDataReader();


dr.Read();
//tbNombre.Text = dr["c1"].ToString();


OracleBlob blob = (OracleBlob)orden.Parameters["c2blob"].Value;

byte filedata = null;
if (blob.Length != 0)
{
filedata = new byte[blob.Length];

}

//these are attempts that I have been making

//dateTime = Convert.ToDateTime(dr["d1"].ToString());
//dateTime = Convert.ToDateTime(dr.GetOrdinal("d1").ToString());
//dateTime = dr["d1"].ToString().Length > 0 ? DateTime.Parse(dr["d1"].ToString()) : DateTime.MinValue;

//dateTime = DateTime.ParseExact(dr["d1"].ToString(),"dd/MM/yyyy",System.Globalization.CultureInfo.CreateSpecificCulture("es-ES"));


player = new Player_E (dr["c1"].ToString(), dr["c2"].ToString(), dr["c3"].ToString(), dateTime, dr["c4"].ToString(), filedata);

//dr.Dispose();


//orden.Dispose();
conexion.Close();
return player;
}


Here is the method where i call for the send the object Player with the values.



Edit: This is the Procedure:



PROCEDURE OBTENER_JUGADOR (v_nombre VARCHAR2,
est_jugador OUT estructura_devuelta,
C2BLOB OUT BLOB)



IS
BEGIN
INSERT INTO TMP_ESTRUCTURA (c1,
c2,
c3,
d1,
c4)
SELECT NOMBRE,
DIRECCION,
PUESTO_HAB,
FECHA_NAC,
EQUIPO_JUGADOR
FROM jugador
WHERE nombre = v_nombre;


SELECT FOTO_JUGADOR
INTO C2BLOB
FROM jugador
WHERE nombre = v_nombre;


OPEN est_jugador FOR SELECT * FROM TMP_ESTRUCTURA;
EXCEPTION
WHEN OTHERS
THEN
raise_application_error (
-20100,
'El jugador ' || v_nombre || ' no existe' || SQLERRM);
END OBTENER_JUGADOR;


Thanks for all










share|improve this question

























  • If you are using the Microsoft Oracle client: docs.microsoft.com/en-us/dotnet/api/…: var dateTime = dr.GetDateTime(0); assuming the ordinal output of the value is 0. If you are not sure get the ordinal position first using GetOrdinal

    – Igor
    Nov 16 '18 at 19:07













  • Hi, thanks for comment, i using Oracle.ManagedDataAccess.Client; and i tried dr.GetString(0); all values is string, (0,1,2,3,4,5) all is string and value null. The structure is string,string,string,date,string,blob. and i get all this for procedure.

    – xLioneth
    Nov 16 '18 at 19:18













  • This type library also has OracleDataReader.GetDateTime() and OracleDataReader.GetOracleDate(), why are you not trying/using those?

    – Igor
    Nov 16 '18 at 19:27











  • I was used while(dr.Read()) { name = dr.GetString(0); ... ... dateTime = dr.GetDateTime(0) } and the value is null but when i use with name = dr["c1"].ToString(); the value isn`t null

    – xLioneth
    Nov 16 '18 at 19:35











  • I've tried again in case I was wrong before and it's the same result. The error is -> the column have data null Unhandled exception of type 'System.InvalidCastException' in Oracle.ManagedDataAccess.dll. the code is jugador = new Jugador_E(dr.GetString(0), dr.GetString(1), dr.GetString(2), dr.GetDateTime(3), dr.GetString(4), filedata);

    – xLioneth
    Nov 16 '18 at 19:41


















0















i need help, when i get the data of procedure BD (Oracle). I do not know how to deal with data type date time, int etc. I only know do with strings



public static Player_E getPlayer(string select)
{
Player_E player = new Player_E();
DateTime? dateTime = new DateTime();

conexion = bd.ConexionWithDB();

orden.CommandText = "CONSULTAS.obtener_jugador";
orden.CommandType = CommandType.StoredProcedure;
orden.Parameters.Add("v_nombre", OracleDbType.Varchar2, 60).Value = select;
orden.Parameters.Add("jugadores_dev", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output);


orden.Parameters.Add("c2blob", OracleDbType.Blob).Direction = ParameterDirection.Output;
orden.Connection = conexion;

orden.ExecuteNonQuery();

OracleDataReader dr = ((OracleRefCursor)orden.Parameters["jugadores_dev"].Value).GetDataReader();


dr.Read();
//tbNombre.Text = dr["c1"].ToString();


OracleBlob blob = (OracleBlob)orden.Parameters["c2blob"].Value;

byte filedata = null;
if (blob.Length != 0)
{
filedata = new byte[blob.Length];

}

//these are attempts that I have been making

//dateTime = Convert.ToDateTime(dr["d1"].ToString());
//dateTime = Convert.ToDateTime(dr.GetOrdinal("d1").ToString());
//dateTime = dr["d1"].ToString().Length > 0 ? DateTime.Parse(dr["d1"].ToString()) : DateTime.MinValue;

//dateTime = DateTime.ParseExact(dr["d1"].ToString(),"dd/MM/yyyy",System.Globalization.CultureInfo.CreateSpecificCulture("es-ES"));


player = new Player_E (dr["c1"].ToString(), dr["c2"].ToString(), dr["c3"].ToString(), dateTime, dr["c4"].ToString(), filedata);

//dr.Dispose();


//orden.Dispose();
conexion.Close();
return player;
}


Here is the method where i call for the send the object Player with the values.



Edit: This is the Procedure:



PROCEDURE OBTENER_JUGADOR (v_nombre VARCHAR2,
est_jugador OUT estructura_devuelta,
C2BLOB OUT BLOB)



IS
BEGIN
INSERT INTO TMP_ESTRUCTURA (c1,
c2,
c3,
d1,
c4)
SELECT NOMBRE,
DIRECCION,
PUESTO_HAB,
FECHA_NAC,
EQUIPO_JUGADOR
FROM jugador
WHERE nombre = v_nombre;


SELECT FOTO_JUGADOR
INTO C2BLOB
FROM jugador
WHERE nombre = v_nombre;


OPEN est_jugador FOR SELECT * FROM TMP_ESTRUCTURA;
EXCEPTION
WHEN OTHERS
THEN
raise_application_error (
-20100,
'El jugador ' || v_nombre || ' no existe' || SQLERRM);
END OBTENER_JUGADOR;


Thanks for all










share|improve this question

























  • If you are using the Microsoft Oracle client: docs.microsoft.com/en-us/dotnet/api/…: var dateTime = dr.GetDateTime(0); assuming the ordinal output of the value is 0. If you are not sure get the ordinal position first using GetOrdinal

    – Igor
    Nov 16 '18 at 19:07













  • Hi, thanks for comment, i using Oracle.ManagedDataAccess.Client; and i tried dr.GetString(0); all values is string, (0,1,2,3,4,5) all is string and value null. The structure is string,string,string,date,string,blob. and i get all this for procedure.

    – xLioneth
    Nov 16 '18 at 19:18













  • This type library also has OracleDataReader.GetDateTime() and OracleDataReader.GetOracleDate(), why are you not trying/using those?

    – Igor
    Nov 16 '18 at 19:27











  • I was used while(dr.Read()) { name = dr.GetString(0); ... ... dateTime = dr.GetDateTime(0) } and the value is null but when i use with name = dr["c1"].ToString(); the value isn`t null

    – xLioneth
    Nov 16 '18 at 19:35











  • I've tried again in case I was wrong before and it's the same result. The error is -> the column have data null Unhandled exception of type 'System.InvalidCastException' in Oracle.ManagedDataAccess.dll. the code is jugador = new Jugador_E(dr.GetString(0), dr.GetString(1), dr.GetString(2), dr.GetDateTime(3), dr.GetString(4), filedata);

    – xLioneth
    Nov 16 '18 at 19:41














0












0








0








i need help, when i get the data of procedure BD (Oracle). I do not know how to deal with data type date time, int etc. I only know do with strings



public static Player_E getPlayer(string select)
{
Player_E player = new Player_E();
DateTime? dateTime = new DateTime();

conexion = bd.ConexionWithDB();

orden.CommandText = "CONSULTAS.obtener_jugador";
orden.CommandType = CommandType.StoredProcedure;
orden.Parameters.Add("v_nombre", OracleDbType.Varchar2, 60).Value = select;
orden.Parameters.Add("jugadores_dev", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output);


orden.Parameters.Add("c2blob", OracleDbType.Blob).Direction = ParameterDirection.Output;
orden.Connection = conexion;

orden.ExecuteNonQuery();

OracleDataReader dr = ((OracleRefCursor)orden.Parameters["jugadores_dev"].Value).GetDataReader();


dr.Read();
//tbNombre.Text = dr["c1"].ToString();


OracleBlob blob = (OracleBlob)orden.Parameters["c2blob"].Value;

byte filedata = null;
if (blob.Length != 0)
{
filedata = new byte[blob.Length];

}

//these are attempts that I have been making

//dateTime = Convert.ToDateTime(dr["d1"].ToString());
//dateTime = Convert.ToDateTime(dr.GetOrdinal("d1").ToString());
//dateTime = dr["d1"].ToString().Length > 0 ? DateTime.Parse(dr["d1"].ToString()) : DateTime.MinValue;

//dateTime = DateTime.ParseExact(dr["d1"].ToString(),"dd/MM/yyyy",System.Globalization.CultureInfo.CreateSpecificCulture("es-ES"));


player = new Player_E (dr["c1"].ToString(), dr["c2"].ToString(), dr["c3"].ToString(), dateTime, dr["c4"].ToString(), filedata);

//dr.Dispose();


//orden.Dispose();
conexion.Close();
return player;
}


Here is the method where i call for the send the object Player with the values.



Edit: This is the Procedure:



PROCEDURE OBTENER_JUGADOR (v_nombre VARCHAR2,
est_jugador OUT estructura_devuelta,
C2BLOB OUT BLOB)



IS
BEGIN
INSERT INTO TMP_ESTRUCTURA (c1,
c2,
c3,
d1,
c4)
SELECT NOMBRE,
DIRECCION,
PUESTO_HAB,
FECHA_NAC,
EQUIPO_JUGADOR
FROM jugador
WHERE nombre = v_nombre;


SELECT FOTO_JUGADOR
INTO C2BLOB
FROM jugador
WHERE nombre = v_nombre;


OPEN est_jugador FOR SELECT * FROM TMP_ESTRUCTURA;
EXCEPTION
WHEN OTHERS
THEN
raise_application_error (
-20100,
'El jugador ' || v_nombre || ' no existe' || SQLERRM);
END OBTENER_JUGADOR;


Thanks for all










share|improve this question
















i need help, when i get the data of procedure BD (Oracle). I do not know how to deal with data type date time, int etc. I only know do with strings



public static Player_E getPlayer(string select)
{
Player_E player = new Player_E();
DateTime? dateTime = new DateTime();

conexion = bd.ConexionWithDB();

orden.CommandText = "CONSULTAS.obtener_jugador";
orden.CommandType = CommandType.StoredProcedure;
orden.Parameters.Add("v_nombre", OracleDbType.Varchar2, 60).Value = select;
orden.Parameters.Add("jugadores_dev", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output);


orden.Parameters.Add("c2blob", OracleDbType.Blob).Direction = ParameterDirection.Output;
orden.Connection = conexion;

orden.ExecuteNonQuery();

OracleDataReader dr = ((OracleRefCursor)orden.Parameters["jugadores_dev"].Value).GetDataReader();


dr.Read();
//tbNombre.Text = dr["c1"].ToString();


OracleBlob blob = (OracleBlob)orden.Parameters["c2blob"].Value;

byte filedata = null;
if (blob.Length != 0)
{
filedata = new byte[blob.Length];

}

//these are attempts that I have been making

//dateTime = Convert.ToDateTime(dr["d1"].ToString());
//dateTime = Convert.ToDateTime(dr.GetOrdinal("d1").ToString());
//dateTime = dr["d1"].ToString().Length > 0 ? DateTime.Parse(dr["d1"].ToString()) : DateTime.MinValue;

//dateTime = DateTime.ParseExact(dr["d1"].ToString(),"dd/MM/yyyy",System.Globalization.CultureInfo.CreateSpecificCulture("es-ES"));


player = new Player_E (dr["c1"].ToString(), dr["c2"].ToString(), dr["c3"].ToString(), dateTime, dr["c4"].ToString(), filedata);

//dr.Dispose();


//orden.Dispose();
conexion.Close();
return player;
}


Here is the method where i call for the send the object Player with the values.



Edit: This is the Procedure:



PROCEDURE OBTENER_JUGADOR (v_nombre VARCHAR2,
est_jugador OUT estructura_devuelta,
C2BLOB OUT BLOB)



IS
BEGIN
INSERT INTO TMP_ESTRUCTURA (c1,
c2,
c3,
d1,
c4)
SELECT NOMBRE,
DIRECCION,
PUESTO_HAB,
FECHA_NAC,
EQUIPO_JUGADOR
FROM jugador
WHERE nombre = v_nombre;


SELECT FOTO_JUGADOR
INTO C2BLOB
FROM jugador
WHERE nombre = v_nombre;


OPEN est_jugador FOR SELECT * FROM TMP_ESTRUCTURA;
EXCEPTION
WHEN OTHERS
THEN
raise_application_error (
-20100,
'El jugador ' || v_nombre || ' no existe' || SQLERRM);
END OBTENER_JUGADOR;


Thanks for all







c# oracle visual-studio






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 19:30







xLioneth

















asked Nov 16 '18 at 18:46









xLionethxLioneth

12




12













  • If you are using the Microsoft Oracle client: docs.microsoft.com/en-us/dotnet/api/…: var dateTime = dr.GetDateTime(0); assuming the ordinal output of the value is 0. If you are not sure get the ordinal position first using GetOrdinal

    – Igor
    Nov 16 '18 at 19:07













  • Hi, thanks for comment, i using Oracle.ManagedDataAccess.Client; and i tried dr.GetString(0); all values is string, (0,1,2,3,4,5) all is string and value null. The structure is string,string,string,date,string,blob. and i get all this for procedure.

    – xLioneth
    Nov 16 '18 at 19:18













  • This type library also has OracleDataReader.GetDateTime() and OracleDataReader.GetOracleDate(), why are you not trying/using those?

    – Igor
    Nov 16 '18 at 19:27











  • I was used while(dr.Read()) { name = dr.GetString(0); ... ... dateTime = dr.GetDateTime(0) } and the value is null but when i use with name = dr["c1"].ToString(); the value isn`t null

    – xLioneth
    Nov 16 '18 at 19:35











  • I've tried again in case I was wrong before and it's the same result. The error is -> the column have data null Unhandled exception of type 'System.InvalidCastException' in Oracle.ManagedDataAccess.dll. the code is jugador = new Jugador_E(dr.GetString(0), dr.GetString(1), dr.GetString(2), dr.GetDateTime(3), dr.GetString(4), filedata);

    – xLioneth
    Nov 16 '18 at 19:41



















  • If you are using the Microsoft Oracle client: docs.microsoft.com/en-us/dotnet/api/…: var dateTime = dr.GetDateTime(0); assuming the ordinal output of the value is 0. If you are not sure get the ordinal position first using GetOrdinal

    – Igor
    Nov 16 '18 at 19:07













  • Hi, thanks for comment, i using Oracle.ManagedDataAccess.Client; and i tried dr.GetString(0); all values is string, (0,1,2,3,4,5) all is string and value null. The structure is string,string,string,date,string,blob. and i get all this for procedure.

    – xLioneth
    Nov 16 '18 at 19:18













  • This type library also has OracleDataReader.GetDateTime() and OracleDataReader.GetOracleDate(), why are you not trying/using those?

    – Igor
    Nov 16 '18 at 19:27











  • I was used while(dr.Read()) { name = dr.GetString(0); ... ... dateTime = dr.GetDateTime(0) } and the value is null but when i use with name = dr["c1"].ToString(); the value isn`t null

    – xLioneth
    Nov 16 '18 at 19:35











  • I've tried again in case I was wrong before and it's the same result. The error is -> the column have data null Unhandled exception of type 'System.InvalidCastException' in Oracle.ManagedDataAccess.dll. the code is jugador = new Jugador_E(dr.GetString(0), dr.GetString(1), dr.GetString(2), dr.GetDateTime(3), dr.GetString(4), filedata);

    – xLioneth
    Nov 16 '18 at 19:41

















If you are using the Microsoft Oracle client: docs.microsoft.com/en-us/dotnet/api/…: var dateTime = dr.GetDateTime(0); assuming the ordinal output of the value is 0. If you are not sure get the ordinal position first using GetOrdinal

– Igor
Nov 16 '18 at 19:07







If you are using the Microsoft Oracle client: docs.microsoft.com/en-us/dotnet/api/…: var dateTime = dr.GetDateTime(0); assuming the ordinal output of the value is 0. If you are not sure get the ordinal position first using GetOrdinal

– Igor
Nov 16 '18 at 19:07















Hi, thanks for comment, i using Oracle.ManagedDataAccess.Client; and i tried dr.GetString(0); all values is string, (0,1,2,3,4,5) all is string and value null. The structure is string,string,string,date,string,blob. and i get all this for procedure.

– xLioneth
Nov 16 '18 at 19:18







Hi, thanks for comment, i using Oracle.ManagedDataAccess.Client; and i tried dr.GetString(0); all values is string, (0,1,2,3,4,5) all is string and value null. The structure is string,string,string,date,string,blob. and i get all this for procedure.

– xLioneth
Nov 16 '18 at 19:18















This type library also has OracleDataReader.GetDateTime() and OracleDataReader.GetOracleDate(), why are you not trying/using those?

– Igor
Nov 16 '18 at 19:27





This type library also has OracleDataReader.GetDateTime() and OracleDataReader.GetOracleDate(), why are you not trying/using those?

– Igor
Nov 16 '18 at 19:27













I was used while(dr.Read()) { name = dr.GetString(0); ... ... dateTime = dr.GetDateTime(0) } and the value is null but when i use with name = dr["c1"].ToString(); the value isn`t null

– xLioneth
Nov 16 '18 at 19:35





I was used while(dr.Read()) { name = dr.GetString(0); ... ... dateTime = dr.GetDateTime(0) } and the value is null but when i use with name = dr["c1"].ToString(); the value isn`t null

– xLioneth
Nov 16 '18 at 19:35













I've tried again in case I was wrong before and it's the same result. The error is -> the column have data null Unhandled exception of type 'System.InvalidCastException' in Oracle.ManagedDataAccess.dll. the code is jugador = new Jugador_E(dr.GetString(0), dr.GetString(1), dr.GetString(2), dr.GetDateTime(3), dr.GetString(4), filedata);

– xLioneth
Nov 16 '18 at 19:41





I've tried again in case I was wrong before and it's the same result. The error is -> the column have data null Unhandled exception of type 'System.InvalidCastException' in Oracle.ManagedDataAccess.dll. the code is jugador = new Jugador_E(dr.GetString(0), dr.GetString(1), dr.GetString(2), dr.GetDateTime(3), dr.GetString(4), filedata);

– xLioneth
Nov 16 '18 at 19:41












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53343699%2fproblem-with-data-processing-oracledatareader-oraclerefcursor%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53343699%2fproblem-with-data-processing-oracledatareader-oraclerefcursor%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values