简体   繁体   English

使用相对路径从ssms数据库检索图像并在C#visual studio 2012的图片框中显示图像?

[英]Retrieving images from ssms Database using relative path and showing image in picture box in C# visual studio 2012?

I am making a win-forms program in C# visual studio. 我正在C#visual studio中制作一个win-forms程序。 I have the relative paths for all the images stored in the database. 我具有存储在数据库中的所有图像的相对路径。 What I am trying to do is make it so that when an item is selected from the combobox, a stored proc is executed it returns the datatable and places everything in the relevant textbox. 我正在尝试做的是,使之从组合框中选择一个项目时,将执行存储的proc,它将返回数据表并将所有内容放置在相关的文本框中。

However, one column is the relative path for the .JPEG image. 但是,一列是.JPEG图像的相对路径。 I need to get the relative path and somehow convert it so that the program gets the actual image and display it in the PictureBox. 我需要获取相对路径并以某种方式对其进行转换,以便程序获取实际图像并将其显示在PictureBox中。

private void cmbEOselect_SelectionChangeCommitted(object sender, EventArgs e)
{
    DataTable SO = new DataTable();

    txtbEOname.Text = (String)SO.Rows[cmbEOselect.SelectedIndex]["Name"];

    String folder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) 
    + @"\........\.jpeg      pBoxOils.Load(folder);
    txtbEObottn = (String)SO.Rows[cmbEOselect.SelectedIndex]["BottanicalName"];
    txtbEOext.Text = (String)SO.Rows[cmbEOselect.SelectedIndex]["Extraction"];

}
txtbEOname.Text = (String)PEO.Rows[cmbEOselect.SelectedIndex]["Name"];
            String folder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) +   @"" + PEO.Rows[cmbEOselect.SelectedIndex]["IMAGE"];
            pBoxOils.Load(folder);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在c#,visual studio 2013中使用数据库文件的相对路径 - Using a relative path for a database file in c#, visual studio 2013 在c#winforms中从数据库检索图像到图片框 - retrieve image to picture box from database in c# winforms 需要一些帮助,使用C#将SQL数据库中的单个文本检索到Visual Studio中的文本框中 - Need some help of retrieving a single text from SQL database into a textbox in Visual Studio using C# 使用C#连接到SQL Server 2012数据库(Visual Studio 2012) - Connect to SQL Server 2012 Database with C# (Visual Studio 2012) 在图片框中设置图片从SQL数据库中检索 - Setting image in picture box retrieving from sql database 使用C#从SQL Server数据库保存和检索图像 - Saving and retrieving of images from SQL Server database using c# 如何使用Visual Studio C#移动图片框的特定部分 - How to move a certain part of a picture box using Visual Studio c# 在Visual C#中从数据库检索数据 - Retrieving data from database in Visual C# 如何使用数据库中的图像路径将图像显示到图片框中 - How to display image into picture box using image path in database 在 Visual Studio 2012 中的 C# 项目中更改文件完整路径 - Change file full path in a C# project in Visual studio 2012
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM