易截截图软件、单文件、免安装、纯绿色、仅160KB

字符串中写SQL语句...

你是否遇到过 想在 字符串里面写 SQL语句,但是总是遇到 某些符号不会写.
比如说在字符串里面写个变量.
like: str  sql="select * from abc where  id= ' "++" ' "
id的变量应 先用单引号然后“+”号。
今天遇到个很长的SQL语句,而且SQL语句里面嵌套了字符串。当时根本不会写,后来在同事帮助下,终于解决了。
方法:
不管字符串多长,只要记住  如果是个变量 就写成   "+变量+"。其它一切不动。
例子:   
else if(DB.getFirst("select parentcategoryid from category where categoryid in
("
+
DB.getFirst("select parentcategoryid from category where categoryid=" +
EnMapArray[cnum] + "
")+"
)") == DB.getFirst("select parentcategoryid from category where categoryid in ("+DB.getFirst("select parentcategoryid from category where categoryid=" + EnMapArray[EnMapArray.Length - 1] + "")+")"))


相关文档:

航空公司管理系统(VC++ 与SQL 2005)

系统环境:Windows 7
软件环境:Visual C++ 2008 SP1 +SQL Server 2005
本次目的:编写一个航空管理系统
      这是数据库课程设计的成果,虽然成绩不佳,但是作为我用VC++ 以来编写的最大程序还是传到网上,以供参考。用VC++ 做数据库设计并不容易,但也不是不可能。以下是我的程序界面,后面 ......

SQL Server中 char与varchar  

固定长度(char)与可变长度(varchar)字符数据类型
char[(n)]
长度为n个字节的固定长度且非Unicode的字符数据。n必须是一个介于1和8,000之间的数值。存储大小为n个字节。char在SQL-92中的同义词为character。
varchar[(n)]
长度为n个字节的可变长度且非Unicode的字符数据。n必须是一个介于1和8,000之间的数值。存储大小为 ......

使用SQL Server导入/导出Excel

使用SQL Server导入/导出Excel,包含部分错误信息处理方法;
操作手记,留此备查
/*
导入
*/
--错误信息如下时:
--Msg 15281, Level 16, State 1, Line 2
--SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as ......

sql choch02

ch02
--3-4
select * from orders
where 'México D.F.' in
(select City
from Customers
where Orders.CustomerID = Customers.CustomerID )
--3-5
select * from orders
where 'usa' =
(select Country
from Customers
where Orders.CustomerID = Customers.CustomerID )
--4-1
select * from or ......

SQL语句导入导出

SQL语句导入导出
/******* 导出到excel
EXEC master..xp_cmdshell 'bcp SettleDB.dbo.shanghu out c:\temp1.xls -c -q -S"GNETDATA/GNETDATA" -U"sa" -P""'
/*********** 导入Excel
SELECT *
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\test.xls";User ID=Admin;Password=;Extended propert ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号