Şimdi Ara

ASP.Net de ufacık bir sorun :)

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
1 Misafir - 1 Masaüstü
5 sn
2
Cevap
0
Favori
1.178
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • <%@ Page Language="C#" Debug="true" %>
    <%@ Import Namespace="System" %>
    <%@ Import Namespace="System.Data.SqlClient" %>

    <script runat="server" language="c#">

    protected void Page_Load()
    {
    SqlConnection Conn = new SqlConnection();
    Conn.ConnectionString = "Integrated Security=SSPI;initial catalog=WebOn;data source=ZERGCOMP-BD43C7\\SQLEXPRESS";

    SqlCommand Cmd = new SqlCommand("select * from Employe_Info",Conn);
    Conn.Open();

    SqlDataReader Dr = Cmd.ExecuteReader();
    int work;

    do
    {

    Response.Write(Dr.GetInt32(0));

    } while (Convert.ToBoolean(Dr.Read()));

    Dr.Close();
    Conn.Close();
    }

    </script>

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    Hata

    Invalid attempt to read when no data is present.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: Invalid attempt to read when no data is present.

    Source Error:

    Line 19: {
    Line 20:
    Line 21: Response.Write(Dr.GetInt32(0));
    Line 22:
    Line 23:


    Source File: c:\Inetpub\wwwroot\learn.netasp\employe_edd\Default.aspx Line: 21

    Stack Trace:

    [InvalidOperationException: Invalid attempt to read when no data is present.]
    System.Data.SqlClient.SqlDataReader.ReadColumn(Int32 i, Boolean setTimeout) +874171
    System.Data.SqlClient.SqlDataReader.GetInt32(Int32 i) +16
    ASP.default_aspx.Page_Load() in c:\Inetpub\wwwroot\learn.netasp\employe_edd\Default.aspx:21
    System.Web.Util.CalliHelper.ArglessFunctionCaller(IntPtr fp, Object o) +5
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +858603
    System.Web.UI.Control.OnLoad(EventArgs e) +99
    System.Web.UI.Control.LoadRecursive() +47
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

    +++++++++++++++++++++++++++++++++++++++++++++++++++++

    Sorun nerede tam olarak çözemedim,birde en alta yer alan hata msj'larının anlamları ne?







  • neden do while döngüsü?
    birde şunu denermisin?
    protected void Page_Load()
    {
    SqlConnection Conn = new SqlConnection();
    Conn.ConnectionString = "Integrated Security=SSPI;initial catalog=WebOn;data source=ZERGCOMP-BD43C7\\SQLEXPRESS";

    // employee info tablosundan ne çekicek?select * from resultset döndürür.örnek şöyle olsa?
    SqlCommand Cmd = new SqlCommand("select employe_bilgisi(kolon olsun bu) from Employe_Info",Conn);
    // employe_bilgisi string deger döndürüyosa:
    Conn.Open();
    SqlDataReader Dr = Cmd.ExecuteReader();
    while (dr.read())
    {
    // test amaçlı response write kullanılabilinir.onun dışında gelen veriyi label'a atmanı tavsiye ederim.
    response.write(dr.getstring(0));
    }
    dr.close();
    conn.close();
    }
    pm atabilirsin
    iyi çalışmalar..



    < Bu mesaj bu kişi tarafından değiştirildi OSIRIS -- 24 Mart 2009; 11:31:13 >




  • 
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.