I have sql database where I have image as saved image location

我有sql数据库,我将图像保存为图像位置

eg:

例如:

D:\Local Pictures\Users\XXXX_XXXX_1.jpg

I am trying to place it in the picture box using this code

我试图使用此代码将其放在图片框中

DataConnection myCon = new DataConnection(); // Contains Data Connection String
SqlConnection con1 = new SqlConnection(@"Data Source=.\SQLS2012;Initial Catalog=test;Integrated Security=True");
con1.Open();
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("SELECT * From USER_TABLE WHERE USERID =" + userIdTextBox.Text,con1);

myReader = myCommand.ExecuteReader();

while (myReader.Read())
{
    nameTextBox.Text = (myReader["FIRST_NAME"].ToString());
    lnameTextBox.Text = (myReader["LAST_NAME"].ToString());
    posTextBox.Text = (myReader["POSITION"].ToString());
    emailTextBox.Text = (myReader["E_MAIL"].ToString());
    phoneTextBox.Text = (myReader["PHONE"].ToString());
    usernameTextBox.Text = (myReader["USERNAME"].ToString());
    userLevelTextBox.Text = (myReader["USER_LEVEL"].ToString());
    string filename = (myReader["PROFILE_PICTURE"].ToString());
    profilePicBox.ImageLocation = filename;

}

When I execute this code I am getting small x picture white background in image. How to fix and load the image

当我执行此代码时,我在图像中获得小x图像白色背景。如何修复和加载图像

2 个解决方案

#1


2

Loading:

加载:

MSDN isn't exactly clear on this matter - ImageLocation property, but it seems that setting the ImageLocation property may not exactly load the image, so you may try to use PictureBox.Load method instead:

MSDN在这个问题上并不完全清楚 - ImageLocation属性,但似乎设置ImageLocation属性可能无法正确加载图像,因此您可能会尝试使用PictureBox.Load方法:

...
string filename = (myReader["PROFILE_PICTURE"].ToString());
profilePicBox.Load(filename);

EDIT

编辑

ImageLocation should probably work fine, just make sure that your paths are correct and you do not use relative paths - How do I put an image into my picturebox using ImageLocation?

ImageLocation应该可以正常工作,只需确保路径正确并且不使用相对路径 - 如何使用ImageLocation将图像放入我的图片框?

Positioning and size:

定位和尺寸:

And make sure that your PictureBox properties related to size and position can handle different image sizes.

并确保与大小和位置相关的PictureBox属性可以处理不同的图像大小。

更多相关文章

  1. Recordset记录集对象的属性
  2. 要在更新属性上执行的TRIGGER?
  3. 使用进度条延迟加载图像会使图像在显示时发生损坏
  4. Android 修改用户图像笔记
  5. 背景图像颜色检测与Android油漆。
  6. Android动画精讲一:从setTranslationX谈属性动画和view动画的区别
  7. googlesamples/android-topeka学习笔记(一)-----一些不知道的属
  8. Android 基本控件的常用属性
  9. 想在android中使用node.js和socket.io发送图像

随机推荐

  1. Android高手进阶教程(五)之----Android
  2. android 组件
  3. android音乐播放器开发_开篇
  4. android ui显示技巧和注意事项
  5. 关于android的各种disk images(看过的讲a
  6. Eclipse中使用Ant打Android包报错解决方
  7. android平台的几个编译命令----make,mmm,
  8. Android:背景渐变色
  9. 【Android(BLE)】Android(BLE)之蓝牙权限
  10. 关于Android(安卓)Studio打包混淆以及上