Data Read Returning (Invalid Attempt to Read when Reader is closed)
By : Fly
Date : March 29 2020, 07:55 AM
wish help you to fix your issue It may have something to do with the fact that the first ittereation would be reader[0] but surely the second itteration will be reader[1], therefore you want to use code :
reader.GetString(0)
reader[0].ToString();
|
No data is read in SqlReader Invalid attempt to read when no data is present.
By : S C P M A X
Date : March 29 2020, 07:55 AM
it helps some times I know this problem has been posted millions of times before, but this might be different. , If you can change the signature of your Handler, then: code :
public bool <YourHandlerName>(out MemoryStream ms)
{
SqlConnection conn = new SqlConnection(@"Server=DEV6\MSSQLHOSTING;Database=Intranet;Trusted_Connection=True;");
conn.Open();
SqlCommand cmd = new SqlCommand("select PDFDocument from LeaveChart where (Year like @Year and Month like @Month)", conn);
cmd.Parameters.AddWithValue("Year", context.Request.QueryString["Year"]);
cmd.Parameters.AddWithValue("Month", context.Request.QueryString["Month"]);
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
ms = new MemoryStream(content);
if(reader.HasRows)
{
byte[] content = (byte[])reader.GetValue(0);
ms.Position = 0;
context.Response.ContentType = "Application/pdf";
ms.WriteTo(context.Response.OutputStream);
context.Response.End();
reader.Close();
conn.Close();
return true;
}
return false;
}
|
Invalid attempt to read data when no data is present when getting all values from a row in a SQL Server table
By : user2566910
Date : March 29 2020, 07:55 AM
may help you . The following code is working fine for me when accessing and reading row(s) from a SQL database. As DJ KRAZE mentioned, always check if you have any rows first. code :
if (reader.HasRows)
{
while (reader.Read())
{
// Read all column data from row here, one row at a time
}
}
|
Getting ORA-01747: invalid user.table.column, table.column, or column specification in Oracle when inserting data using
By : Richard Le
Date : March 29 2020, 07:55 AM
it should still fix some issue The only way I can immediately see to get that error from insert is if you're passing the column name enclosed in single-quotes; you haven't shown the call and it's unlikely you'd do this from a SQL client (more likely you added quotes incorrectly in a JDBC/PHP/etc. parameter), but calling like this: code :
exec sp_get_all_records(6372325, '''MC1''', :detail);
INSERT INTO COUNT_MASTER_TEMP SELECT COUNT (ar.'MC1')
FROM app_recipient ar
WHERE EXISTS (SELECT r.'MC1' FROM app_recipient r
WHERE r.ID =6372325 AND ar.'MC1'= r.'MC1')
ORA-01747: invalid user.table.column, table.column, or column specification
ORA-06512: at "SCHEMA.SP_GET_ALL_RECORDS", line 17
ORA-06512: at line 1
'WHERE' ||'r.'||v_mc || '= ANY
(SELECT ar.'||v_mc || 'FROM app_recipient ar WHERE r.ID =' || p_id || ')
' WHERE ' ||'r.'||v_mc || '= ANY
(SELECT ar.'||v_mc || ' FROM app_recipient ar WHERE r.ID =' || p_id || ')
WHERE r.'||v_mc ||'= ANY (SELECT ar.'||v_mc ||'FROM app_recipient ar WHERE r.ID =' ||v_master_id || ')';
WHERE r.'||v_mc ||'= ANY (SELECT ar.'||v_mc ||' FROM app_recipient ar WHERE r.ID =' ||v_master_id || ')';
|
Getting error "Invalid attempt to read when no data is present" while reading the value of a column of databas
By : Sam
Date : March 29 2020, 07:55 AM
I hope this helps . You need to call the Read method before trying to get something out of a DataReader even if you call HasRows and it returns true. The call to Read is required because after executing the command to get back the reader this object doesn't contain the data from the first record and only after a Read you can start to get your data. code :
If reader.Read() Then
name = reader("UserFirstName").ToString
MsgBox(name)
End If
|