如何加载图片在sql server中
我不知道如何在sql server中存储图片,那位给我仔细的讲一下步骤。
不要存bit型在数据库中,存路径就可以了
这样项目建一个文件夹下,没有图片都有路径了存起来
保存路径到数据库
或保存二进制到到Image字段
using(SqlConnection conn=new SqlConnection(ConnectString))
{
conn.Open();
string strsql = "select photo from testimage where id=" + Request.QueryString["id"];
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = strsql;
SqlDataReader rd = cmd.ExecuteReader();
byte[] data = null;
if (rd.Read())
{
Response.Clear();
data = (byte[])rd["photo"];
Response.BinaryWrite(data);
Response.End();
}
}
Stream ImageStream;
string Path = FileUpload1.PostedFile.FileName;
int Size = FileUpload1.PostedFile.ContentLength;
string Type = FileUpload1.PostedFile.ContentType;
ImageStream = FileUplo
相关问答:
两种错误:
1.如果我这样申明:ResultSet rs;错误提示如下:
An error occurred at line: 51 in the jsp file: /index.jsp
The local variable rs may not have been initialized
48: ......
PB中开发的。
DateTime startTime=DateTime(em_1.Text)
DateTime endTime=DateTime(em_2.Text)
string sql
sql = dw_1.GetSQLSelect()+"Where (StartTime> '"+startTime+&q ......
我有一个月和日组成的数字,有两组月和日
想在身份证号中挑选出在该该两组月日之间出生的人,不知道应该怎么写.
身份证号有可能是15位或者18位
月日组合的形式如下
10-17/04-20
月-日/月- ......
DateTime startTime=DateTime(em_1.Text)
DateTime endTime=DateTime(em_2.Text)
string sql
sql = dw_1.GetSQLSelect()+"Where (StartTime> '"+startTime+"') and (EndTime ......