نمایش نتایج 1 تا 2 از 2

نام تاپیک: not all code pathes return value

  1. #1
    کاربر دائمی
    تاریخ عضویت
    شهریور 1382
    محل زندگی
    عالم ماده
    پست
    977

    not all code pathes return value

    		public bool bindToDatGrid(int x)
    {
    try
    {
    SqlConnection cnn = new
    SqlConnection("server=(local);uid=sa;p wd=yaali;database=MDB" );

    SqlDataAdapter sqlDataAdapter1 = new
    SqlDataAdapter("select * from tblPictures",cnn);

    sqlDataAdapter1.SelectCommand.CommandText = "Select * From tblPictures id = "
    + Convert.ToString(x);

    DataSet ds = new DataSet();
    sqlDataAdapter1.Fill(ds, "tblPictures");

    DataGrid1.DataSource = ds.Tables["tblPictures"].DefaultView;
    DataGrid1.DataBind();

    if (ds.Tables[0].Rows.Count == 0)
    return false;

    // populate the hidden answers:
    // now we need to get the picture from the DataRow
    // and assign it to a byte array

    byte[] MyData =null;
    MyData = (byte[])ds.Tables[0].Rows& #91;0]["Image"];

    int ArraySize = new int();
    ArraySize = MyData.GetUpperBound(0);

    // Create a Filestream for writing the byte array to a gif file (the original format in this case)
    FileStream fs = new FileStream("web.gif", FileMode.OpenOrCreate, FileAccess.Write);

    // Write the stream of data that we read in from the database to the filestream and close it.
    // This will create the file tmp.gif, which we can use to display in the picturebox

    fs.Write(MyData, 0,ArraySize+1); // don't ask me why, but I had to add 1 here for this to work
    fs.Close();

    // Assign the temporary gif file to the picture box

    //pictureBox1.Image = new Bitmap("web.gif");
    Image1.ImageUrl= new Bitmap("Web.Gif").ToString();
    return true;
    }
    catch (Exception ex)
    {
    Response.Write(ex.Message.ToString()&# 41;;
    }

    }

    کد فوق جهت خواندن داده از بانک اسکیوئل برای نمایش عکس است:
    d:\inetpub\wwwroot\InsertImage\WebForm1.aspx.c  s(55): 'InsertImage.WebForm1.bindToDatGrid(int)'&  #58; not all code paths return a value


    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tblPictures&#93  ;') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [dbo].[tblPictures]
    GO

    CREATE TABLE [dbo].[tblPictures] (
    [id] [int] NOT NULL ,
    [Image] [varbinary] (50) NULL
    ) ON [PRIMARY]
    GO


  2. #2
    کاربر دائمی
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    ایران - تهران
    پست
    2,342
    شما از try و catch استفاده کرده اید و نوع تابع شما هم bool است. در بدنه ی try و یا در بدنه ی catch باید حتما true و یا false بر گردانده شود تا تابع خروجی داشته باشد.

تاپیک های مشابه

  1. مشکل عجیب با return false
    نوشته شده توسط shahroozj در بخش ASP.NET Web Forms
    پاسخ: 3
    آخرین پست: چهارشنبه 10 مرداد 1386, 10:43 صبح
  2. return 0 or return 1
    نوشته شده توسط amir_civil در بخش برنامه نویسی با زبان C و ++C
    پاسخ: 2
    آخرین پست: پنج شنبه 04 مرداد 1386, 15:30 عصر
  3. com return
    نوشته شده توسط benyamin_pc در بخش C#‎‎
    پاسخ: 1
    آخرین پست: پنج شنبه 14 دی 1385, 07:21 صبح
  4. return در MessegeBox سفارشی
    نوشته شده توسط Amir Oveisi در بخش C#‎‎
    پاسخ: 1
    آخرین پست: شنبه 17 تیر 1385, 22:20 عصر
  5. مشکل در return کردن
    نوشته شده توسط mr_esmaily در بخش برنامه نویسی با زبان C و ++C
    پاسخ: 2
    آخرین پست: جمعه 03 مهر 1383, 13:29 عصر

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •