动态网站制作指南
[  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
电脑书籍下载:程序设计书籍 | 数据库教程书籍 | 平面与多媒体书籍 | 网络通讯书籍 | 系统管理书籍 | 网络安全书籍 | 认证考试书籍
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > 数据库学院 > 数据库技巧
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
数据库:数据库教程,数据库技巧,Oracle教程,MySQL教程,Access教程,DB2教程,数据库安全,数据库文摘
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ 数据库技巧 ]的信息



本月文章推荐
.深入讲解SQL Union和Union All的.
.深入浅出SQL教程之SELECT语句的自.
.分析及解决SQLServer死锁问题.
.讲解SQL Server数据库备份的多种.
.Sql Server 2000数据库日志日益庞.
.MS SQL SERVER2005 XML 最佳实践.
.Informix中查询database和table的.
.SQL安装问题总结 .
.SQL Server静态页面导出技术3.
.SQL 查询语句积累.
.对系统默认的约束名和索引名进行.
.关于SQL SERVER建立索引需要注意.
.列出SQL SERVER 所有表,字段名,.
.SQL Server 2005数据库恢复脚本示.
.如何转移SQL SERVER数据库.
.利用自定义分页技术提高数据库性.
.实例讲解MSDB数据库置疑状态的解.
.最详细的SQL注入相关的命令整理.
.MS SQL Server存储过程参数的隐式.
.SQL SERVER 2005 EXPRESS不能远程.

如何将图片存到数据库中?

文章类别:数据库技巧 | 发表日期:2001-4-2 |


如果你用的是sql server数据库!你不想用后台操作你可以看看这个
下面是对text的操作你可以看看
1. 写操作(WRITETEXT)
这里一般要用到的函数有TextPtr获得文本字段的指针,和TextVaild检验指针的有效性,@@RowCount判断返回记录的条数。
其基本方法是:用Textptr函数得到指针,判断其有效性,用Writetext写数据
函数说明:Textptr(字段名)。Writetext   tablename。Fieldname   @textptr(指针) [With Log]  data(数据)
例如:
Begin Tran
Declare  @Mytextptr   VarBinary(16)   
Select   @mytextptr=textptr(pr_info)
From  Pub_Info (updlock)
Where  pud_id=’9999’
IF  @Mytextptr Is Not Null
Writetext  pub_info.pr_info   @mytextptr   with log  ‘data’
Commit  Tran
2. 读操作
常用函数
PatIndex(‘%exp%’,var|fieldname。。)
Datalength()
@@TextSize 文本大小
SettextSize  N 设置文本大小
ReadText  {TableName。FieldName}  {@textptr}  Offet  Size   [HoldLock]
例如:
begin tran
Declare  @mytextptr  Varbinary(16),@Totalsize   int,@Readsize  int,@lastread  int
Set textsize 100
Select  @mytextptr=textptr(pr_info), @totalsize=datalength(pr_info)
@lastread=0,
@readsize= case  when  (textsize<datalength(pr_info) then  textsize
eles datalength(pr_info)
end
From  Pub_info
Where  Pub_id=’1622’
IF  @mytextptr Is  not Null  and @readsize>0
While (@lastread<@totalsize)
ReadText  pub_info.pr_info   @mytextptr   @lastread   @readsize  holdlock
If (@@error<>0)
  Break
Select @lastread=@lastread+@readsize
If ((@readsize+@lastread)>@totalsize)
Select @readsize=@totalsize-@lastread
End
Commit  Tran
3.数据更新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 tran
Select  @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  int
Begin  tran
Select @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  log
Commit  tran
例如3:
文本追加的问题
将出版商pub_id=9952的内容追加到出版商Pub_id=0877d的文本中。
Delcare  @source_textptr  varbinary(16),@target_textptr  varbinary(16)
Begin  tran
Select  @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 null
Updatetext  pub_info.pr_infro  @target_textptr  null  null  
with  log   pub_info.pr_infro  @source_textptr


上一篇:在SQLServer中怎么样恢复数据的存储? 人气:10466
下一篇:win98+PWS环境下连接读取远程SQLServer 人气:11033
点击此处浏览全部的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-5-20 站长俱乐部新闻发布系统 v5.19
2008-5-20 DotNetTextBox网页编辑器 v3.4.7
2008-5-20 phpMyFAQ v2.5.0 多国语言版
2008-5-20 DreamArticle 文章管理系统 v2.0
2008-5-20 Drupal v7.xdev Build080518
2008-5-20 逐迹内容管理系统AspxNuke v2.0.
2008-5-20 ajax奥运留言本 v1.0
2008-5-20 QQ空间博客全自动挂机互踩好友
2008-5-20 网人采集 v1.2.0
2008-5-7 Windows XP SP3 官方英文版
2008-5-7 Windows XP SP3 官方香港中文版
2008-5-7 Windows XP SP3 官方繁体中文版
2008-5-7 Windows XP SP3 官方简体中文版
2008-4-30 Multiple Unzip Wizard 1.02
2008-4-30 Multiple Unrar Wizard 1.0.0
2008-4-30 WinZip Install/Try/Uninstall a
2008-4-30 ZIP压缩文件修复器WzipFix 2.0
2008-4-30 Pentazip 6.01 Build 189 For Wi
  发表评论
姓 名: 验证码: [ 全部贴吧 ] [ 浏览评论 ]
内 容:
[ 汉字翻译拼音 ] [ 广告代码 ] [ 符号对照表 ] [ 进制转换 ] [ 经典小工具 ] [ 个税计算 ] [ 汉字简繁转换 ] [ 普通单位换算 ] [ 公制单位换算 ]
[ 生辰老黄历 ] [ 国内电话区号 ] [ 国家代码与域名缩写 ] [ 文字加密解密 ] [ 健康查询 ] [ 万年历 ] [ 手机号码查询 ] [ ip搜索 ] [ Google PR查询 ]
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号