用户名:
密 码: 记住
您当前的位置:首页 > 网络编程 > sqlserver教程

将SQL语句转换为符合VB.NET格式字符串

时间:2014-11-30  来源:互联网  作者:佚名

实习中时常需要将写好的SQL(SQL Server培训 mySQL培训 )语句嵌入到VB(VB培训 ).NET(.NET培训 )的函数中,例如将下列SQL:

-- Get Mother Lot Common Info

select c.customerlotnumber -- customer lot#

,c.containername --Amkor lot#,

,amk.description

,inh.txndate indate--s_time

,outh.txndate outdate -- e-time

,rs.resourcename resourcename

,emp.fullname

-- ,outh.qty

from container c,historymainline hml,workflowstep wfs

,operation opt,movehistory outh,moveinhistory inh

,RESOURCEDEF rs

,amkorwwoper amk

,employee emp

where c.splitfromid =(select containerid from container where

containername='ML6410058461')

and hml.reversalstatus=1

and c.containerid=hml.containerid

and hml.operationid=opt.operationid

and hml.workflowstepid=wfs.workflowstepid

and hml.operationid=opt.operationid

and hml.historymainlineid=inh.historymainlineid(+)

and hml.historymainlineid=outh.historymainlineid(+)

and HMl.RESOURCEID=RS.RESOURCEID(+)

and (outh.historymainlineid is not null or inh.historymainlineid is not null)

and opt.amkorwwoperid=amk.amkorwwoperid

and hml.employeeid=emp.employeeid

order by c.containername,to_number(wfs.sequence),inh.txndate,outh.txndate

转换如下形式为:

String sql in VB.NET

sql = "select c.customerlotnumber -- customer lot# " & vbCrLf _

& ",c.containername --Amkor lot#, " & vbCrLf _

& ",amk.description " & vbCrLf _

& ",inh.txndate indate--s_time " & vbCrLf _

& ",outh.txndate outdate -- e-time " & vbCrLf _

& ",rs.resourcename resourcename " & vbCrLf _

& ",emp.fullname " & vbCrLf _

& "-- ,outh.qty " & vbCrLf _

& "from container c,historymainline hml,workflowstep wfs " & vbCrLf _

& ",operation opt,movehistory outh,moveinhistory inh " & vbCrLf _

& ",RESOURCEDEF rs " & vbCrLf _

& ",amkorwwoper amk " & vbCrLf _

& ",employee emp " & vbCrLf _

& "where c.splitfromid =(select containerid from container where " & vbCrLf _

& "containername='ML6410058461') " & vbCrLf _

& "and hml.reversalstatus=1 " '..

同事Tracy告诉我一个快速方法,仅仅利用UltraEdit的查找替换功能(号不填,仅为引用号),

查找:

替换:

替换的第一个"号前不可省去空格,然后填上头尾即可,^p代表回车符,也就是将回车符展开,是不是很有趣的技巧?

(T114)

来顶一下
返回首页
返回首页
推荐资讯
从零开始学ASP.NET-基础篇第1/7页 从零开始学ASP.NET-基础篇第1/7页第一天 学习目的: 掌握最基本的Label、TextBox、Button控件
ASP.NET入门数据篇 ASP.NET入门数据篇对于网站编程的初学者来说,总是会上网找些源码来看,但久而
相关文章
栏目更新
栏目热门