如何将图片存到数据库中?
如果你用的是sql server数据库!你不想用后台操作你可以看看这个下面是对text的操作你可以看看1. 写操作(WRITETEXT)这里一般要用到的函数有TextPtr获得文本字段的指针,和TextVaild检验指针的有效性,@@RowCount判断返回记录的条数。其基本方法是:用Textptr函数得到指针,判断其有效性,用Writetext写数据函数说明:Textptr(字段名)。Writetext;;;tablename。Fieldname;;;@textptr(指针) [With Log];;data(数据)例如:Begin TranDeclare;;@Mytextptr;;;VarBinary(16);;;Select;;;@mytextptr=textptr(pr_info)From;;Pub_Info (updlock)Where;;pud_id=’9999’IF;;@Mytextptr Is Not NullWritetext;;pub_info.pr_info;;;@mytextptr;;;with log;;‘data’Commit;;Tran2. 读操作常用函数PatIndex(‘%exp%’,var|fieldname。。)Datalength()@@TextSize 文本大小SettextSize;;N 设置文本大小ReadText;;{TableName。FieldName};;{@textptr};;Offet;;Size;;;[HoldLock]例如:begin tranDeclare;;@mytextptr;;Varbinary(16),@Totalsize;;;int,@Readsize;;int,@lastread;;intSet textsize 100Select;;@mytextptr=textptr(pr_info), @totalsize=datalength(pr_info)@lastread=0,@readsize= case;;when;;(textsize<datalength(pr_info) then;;textsizeeles datalength(pr_info)endFrom;;Pub_infoWhere;;Pub_id=’1622’IF;;@mytextptr Is;;not Null;;and @readsize>0 While (@lastread<@totalsize)ReadText;;pub_info.pr_info;;;@mytextptr;;;@lastread;;;@readsize;;holdlockIf (@@error<>0);;BreakSelect @lastread=@lastread+@readsizeIf ((@readsize+@lastread)>@totalsize)Select @readsize=@totalsize-@lastreadEndCommit;;Tran3.数据更新UpdateText更新数据代替了写操作,其基本语法是:UpdateText;;Table_Name.Col_Name;;Text_Ptr;;Offest(偏移量);;;Deleted_Length [With Log] [Inserted_Data|Table_Name.Scr_Column_name;;;Str_Text_Ptr]说明:Offest:0说明从开头开始,Null表示你向当前内容追加数据。Deleted_Length:0表示不删除任何内容,Null表示删除所有内容。例如1(完全代替):Declare;;@mytextptr varbinary(16)Begin tranSelect;;@mytextptr=textptr(pr_infro);;from;;pub_info(uplock);;where;;pub_id=’9999’If;;@mytextptr is not null Updatetext;;pub_info.pr_infro;;@mytextptr;;0;;null;;with;;log;;“you are right”Commit例如2:declare;;@mytextptr;;varbinary(16) ,@offest;;intBegin;;tranSelect @mytextptr=textptr(pr_infro),@offest=patindex(‘%D.C%’,pr_infro)-1+4/*减一是因为有一个矫正的偏移量,加4是因为D.C.是4*/from;;pub_info(unlock);;where;;pub_id=’0877’If;;@mytextptr is;;not;;null;;and;;@offest>=0;;;Updatetext;;pub_info.pr_infro;;@mytextptr;;@offest;;null;;with;;logCommit;;tran例如3:文本追加的问题将出版商pub_id=9952的内容追加到出版商Pub_id=0877d的文本中。Delcare;;@source_textptr;;varbinary(16),@target_textptr;;varbinary(16)Begin;;tranSelect;;@source_textptr=textptr(pr_infro);;from;;pub_info(uplock);;where;;pub_id=’0877’Select;;@target_textptr=textptr(pr_infro);;from;;pub_info(uplock);;where;;pub_id=’9952’If;;@source_textptr Is not null;;and;;@target;;I s;;not nullUpdatetext;;pub_info.pr_infro;;@target_textptr;;null;;null;;with;;log;;;pub_info.pr_infro;;@source_textptr
相关文章:
热门推荐
- FreeBSD Apache+Mysql+Php4的安装
- 1.Linux系统下http服务不能解释php的问题
- 2.abcache php加速
- 3.如何在FreeBSD上用PHP实现在线添加FTP用户
- 4.Solaris如何增加用户?(groupadd,useradd)
- 5.Linux命令Man解释:groupadd :建立新组
- 6.配合QMAIL邮件系统:SOLARIS + HTTPD + MYSQL + PHP + LIMITIP
- 7.ie6不兼容hover ie6 a hover属性失效解决办法
- 8.Solaris 10整合apache与php过程及出错处理
- 9.Linux系统中自带Mysql、Apache、Php卸载
- 10.FreeBSD下安装MySQL+Apache+PHP新手指南