上传&检索图像路径到&来自Sql Server数据库 [英] Upload & Retrieve Image path to & from Sql Server Database

查看:63
本文介绍了上传&检索图像路径到&来自Sql Server数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大家好



问题1:

我正在做一个Windows桌面(C#)应用程序,并希望将图像路径保存到sql server 2008数据库。



问题2:

保存后,检索路径并在不同表格上显示。



任何帮助或网站链接将不胜感激。我已经尝试了谷歌和其他网站,但没有帮助。



最基本的问候

Hi Guys

Problem 1:
Im doing a Windows Desktop (C#) Application and want to save an image path to a sql server 2008 database.

Problem 2:
Once its saved, to retrieve the path & display it on different forms.

Any help or website links would be appreciated. I've tried google & other websites but no help.

Kindest Regards

推荐答案

只需创建一个sql server上的NVARCHAR字段,并以字符串形式传递路径。



Just create a NVARCHAR field on sql server and pass the path through as a string.

using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand com = new SqlCommand("INSERT INTO myTable (imagePath) VALUES (@IM)", con))
        {
        com.Parameters.AddWithValue("@IM", @"C:\My Images\the name of the image.jpg");
        com.ExecuteNonQuery();
        }
    }


谢谢...



遇到问题



@C:\ My Images \ the image of the image.jpg;



但我正在忙着排除故障。



问候
Thank you...

Having problems with

@"C:\My Images\the name of the image.jpg");

but im busy troubleshooting.

Regards


这篇关于上传&检索图像路径到&来自Sql Server数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆