在项目中,经常会遇到需要定时完成的任务,比如定时更新数据,定义统计数据生成报表等等,其实这些事情都可以使用Oracle的Job来完成。下面就结合我们实验室项目实际,简单介绍一下在Oracle数据库中通过Job完成自动创建表的方法。
查看全文在项目中,经常会遇到需要定时完成的任务,比如定时更新数据,定义统计数据生成报表等等,其实这些事情都可以使用Oracle的Job来完成。下面就结合我们实验室项目实际,简单介绍一下在Oracle数据库中通过Job完成自动创建表的方法。
查看全文 select * from USER_INFO where country=`China`
select * from USER_INFO where country=`CHINA`
想让两者查询结果一样
SQL语句应怎么写。
select * from USER_INFO where lower(country)='china'
补充:
在Oracle中,upper() or lower()函数都可以实现不区分大小写的功能
引用:http://www.itpub.net/thread-1022799-1-1.html
用create as select创建的表无法删除???
SQL> create table t as select rownum id,a.* from dba_catalog a;
表已创建。
SQL> desc t;
名称 是否为空? 类型
----------------------------------------- -------- ----------------------------
ID NUMBER
OWNER NOT NULL VARCHAR2(30)
TABLE_NAME NOT NULL VARCHAR2(30)
TABLE_TYPE VARCHAR2(11)
SQL> drop table t;
drop table t
*
第 1 行出现错误:
ORA-00604: 递归 SQL 级别 1 出现错误
ORA-01422: 实际返回的行数超出请求的行数
为什么会无法删除呢,请问遇到类似的问题应该如何着手,应该从哪方面想
原因:在dual表中插入了数据,从而造成了drop表表的问题。
清空dual表中的数据,问题即解决!
在Sql Server中可用+进行字符串连接.
select 'fdkjs'+'kdjfksjd' from tbl
在oracle中是用||进行字符串连接
select 'TBL_programme_' || to_char(sysdate, 'yyyymmdd') from dual;
磁盘分区取整的小方法 查看全文
ASP.NET中下载文件
//TransmitFile实现下载 protected void Button1_Click(object sender, EventArgs e) { /* 微软为Response对象提供了一个新的方法TransmitFile来解决使用Response.BinaryWrite 下载超过400mb的文件时导致Aspnet_wp.exe进程回收而无法成功下载的问题。 代码如下: */ Response.ContentType = "application/x-zip-compressed"; Response.AddHeader("Content-Disposition", "attachment;filename=z.zip"); string filename = Server.MapPath("DownLoad/z.zip"); Response.TransmitFile(filename); } //WriteFile实现下载 protected void Button2_Click(object sender, EventArgs e) { /* using System.IO; */ string fileName = "asd.txt";//客户端保存的文件名 string filePath = Server.MapPath("DownLoad/aaa.txt");//路径 FileInfo fileInfo = new FileInfo(filePath); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName); Response.AddHeader("Content-Length", fileInfo.Length.ToString()); Response.AddHeader("Content-Transfer-Encoding", "binary"); Response.ContentType = "application/octet-stream"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); Response.WriteFile(fileInfo.FullName); Response.Flush(); Response.End(); } //WriteFile分块下载 protected void Button3_Click(object sender, EventArgs e) { string fileName = "aaa.txt";//客户端保存的文件名 string filePath = Server.MapPath("DownLoad/aaa.txt");//路径 System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath); if (fileInfo.Exists == true) { const long ChunkSize = 102400;//100K 每次读取文件,只读取100K,这样可以缓解服务器的压力 byte[] buffer = new byte[ChunkSize]; Response.Clear(); System.IO.FileStream iStream = System.IO.File.OpenRead(filePath); long dataLengthToRead = iStream.Length;//获取下载的文件总大小 Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName)); while (dataLengthToRead > 0 && Response.IsClientConnected) { int lengthRead = iStream.Read(buffer, 0, Convert.ToInt32(ChunkSize));//读取的大小 Response.OutputStream.Write(buffer, 0, lengthRead); Response.Flush(); dataLengthToRead = dataLengthToRead - lengthRead; } Response.Close(); } } //流方式下载 protected void Button4_Click(object sender, EventArgs e) { string fileName = "aaa.txt";//客户端保存的文件名 string filePath = Server.MapPath("DownLoad/aaa.txt");//路径 //以字符流的形式下载文件 FileStream fs = new FileStream(filePath, FileMode.Open); byte[] bytes = new byte[(int)fs.Length]; fs.Read(bytes, 0, bytes.Length); fs.Close(); Response.ContentType = "application/octet-stream"; //通知浏览器下载文件而不是打开 Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); } //---------------------------------------------------------- public void DownloadFile( System.Web.UI.Page WebForm,String FileNameWhenUserDownload ,String FileBody ) { WebForm.Response.ClearHeaders(); WebForm.Response.Clear(); WebForm.Response.Expires = 0; WebForm.Response.Buffer = true; WebForm.Response.AddHeader("Accept-Language", "zh-tw"); //'文件名称 WebForm.Response.AddHeader("content-disposition", "attachment; filename='"+System.Web.HttpUtility.UrlEncode(FileNameWhenUserDownload, System.Text.Encoding.UTF8)+"'"); WebForm.Response.ContentType = "Application/octet-stream"; //'文件内容 WebForm.Response.Write(FileBody);//----------- WebForm.Response.End(); } //上面这段代码是下载一个动态产生的文本文件,若这个文件已经存在于服务器端的实体路径,则可以通过下面的函数: public void DownloadFileByFilePath( System.Web.UI.Page WebForm,String FileNameWhenUserDownload ,String FilePath ) { WebForm.Response.ClearHeaders(); WebForm.Response.Clear(); WebForm.Response.Expires = 0; WebForm.Response.Buffer = true; WebForm.Response.AddHeader("Accept-Language", "zh-tw"); //文件名称 WebForm.Response.AddHeader("content-disposition", "attachment; filename='" + System.Web.HttpUtility.UrlEncode(FileNameWhenUserDownload, System.Text.Encoding.UTF8) +"'" ); WebForm.Response.ContentType = "Application/octet-stream"; //文件内容 WebForm.Response.Write(System.IO.File.ReadAllBytes(FilePath));//--------- WebForm.Response.End(); } |
用DataFormatString格式化GridView DataFormatString="{0:格式字符串}" 在DataFormatString 中的 {0} 表示数据本身,而在冒号后面的格式字符串代表所们希望数据显示的格式; 数字、货币格式: 格式字符串 输入 结果 常用的日期时间格式: 格式 说明 输出格式 track:http://hi.baidu.com/shunxinyangkun/blog/item/4e982e223d07a1a74623e8bb.html |
我们知道,为了使对于普通 HTML 元素的title可以换行,至少可以有可以两种方式:
1。将title的文本分行写
<a href="#" title="hello
world">hello world</a>2。插入换行符号
<a href="#" title="hello#&10;world">hello world</a>
<a href="#" title="hello#&13;world">hello world</a>10与13分别是换行符与回车符的ACII十进制值
如果需要对WebControl设置title(其实是tooltip属性)这两种方法都失效了,
而是只需要插入编程语言内置的换行符,比如C# 插入 n
<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink>
HyperLink1.ToolTip = "hellonworld";
如果还是输入#&10;或者#&13;asp.net会自动将&编码成 & 。
附录:最简单代码实现的DIV显示Tooltip效果
<HTML>
<HEAD>
<title>Tooltip</title>
<STYLE type="text/css">
body{
font-size:12px;
}
.dek { Z-INDEX: 200; VISIBILITY: hidden; POSITION: absolute ; background:#CCCCCC;}
.bd{
width:100px;
padding:5px;
}
.top{
height:20px;
width:100px;
background-color:#333333;
color:#FFFFFF;
padding:5px;
}
</STYLE>
</HEAD>
<body>
<DIV class="dek" id="dek"></DIV>
<SCRIPT>
Xoffset=-20;
Yoffset= 20;
var nav,old,iex=(document.all),yyy=-1000;
if(navigator.appName=="Netscape"){(document.layers)?nav=true:old=true;}
if(!old)
{
var skn=(nav)?document.dek:dek.style;
if(nav)document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=get_mouse;
}
function popup(msg)
{
var content="<div class='top'>内容提要</div><div width=100 class='bd'>"+msg+"</div>";
if(old){alert(msg);return;}
else{yyy=Yoffset;
if(nav){skn.document.write(content);skn.document.close();skn.visibility="visible"}
if(iex){document.all("dek").innerHTML=content;skn.visibility="visible"}
}
}
function get_mouse(e)
{
var x=(nav)?e.pageX:event.x+document.body.scrollLeft;skn.left=x+Xoffset;
var y=(nav)?e.pageY:event.y+document.body.scrollTop;skn.top=y+yyy;
}
function kill()
{
if(!old){yyy=-1000;skn.visibility="hidden";}
}
</SCRIPT>
<span onMouseOver="popup('显示的提示信息,显示的提示信息!!!');" onmouseout="kill();">普通文字上的效果
</span>
<div>
<img src="image4.jpg" onMouseOver="popup('显示的提示信息,显示的提示信息!!!');" onmouseout="kill();"/>
<p>
图片上的效果
</p>
</div>
<div onMouseOver="popup('显示的提示信息,显示的提示信息!!!');" onmouseout="kill();" class="top">
层上的效果
</div>
</body>
</HTML>
ASPNET中连接字符串
在MSDN中,.net的数据库连接字符串都有详细的说明,我这里以代码范例的方式罗列一些,具体的每一项代表的意义可以参看MSDN.
ADO.net 中数据库连接方式(微软提供)
微软提供了以下四种数据库连接方式:
System.Data.OleDb.OleDbConnection
System.Data.SqlClient.SqlConnection
System.Data.Odbc.OdbcConnection
System.Data.OracleClient.OracleConnection
下面我们以范例的方式,来依次说明:
System.Data.SqlClient.SqlConnection
常用的一些连接字符串(C#代码):
SqlConnection conn
= new SqlConnection( "Server=(local);Integrated Security=SSPI;database=Pubs");
SqlConnection conn
= new SqlConnection("server=(local)NetSDK;database=pubs;Integrated Security=SSPI");
SqlConnection conn = new SqlConnection(
"Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;");
SqlConnection conn = new SqlConnection(
" data source=(local);initial catalog=xr;integrated security=SSPI;
persist security info=False;workstation id=XURUI;packet size=4096; ");
SqlConnection myConn = new
System.Data.SqlClient.SqlConnection("Persist Security Info=False;Integrated
Security=SSPI;database=northwind;server=mySQLServer");
SqlConnection conn = new SqlConnection(
" uid=sa;pwd=passwords;initial catalog=pubs;data source=127.0.0.1;Connect Timeout=900");
更多字符串连接说明请看MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataSqlClientSqlConnectionClassConnectionStringTopic.asp
System.Data.OleDb.OleDbConnection
常用的一些连接字符串(C#代码):
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:MyWeb815GrocerToGo.mdb");
OleDbConnection conn = new OleDbConnection(
@"Provider=Microsoft.Jet.OLEDB.4.0;Password=;
User ID=Admin;Data Source=grocertogo.mdb;");
OleDbConnection conn = new OleDbConnection(
"Provider=MSDAORA; Data Source=ORACLE8i7;Persist Security Info=False;Integrated Security=yes");
OleDbConnection conn = new OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:binLocalAccess40.mdb");
OleDbConnection conn = new OleDbConnection(
"Provider=SQLOLEDB;Data Source=MySQLServer;Integrated Security=SSPI");
System.Data.OracleClient.OracleConnection
常用的一些连接字符串(C#代码):
OracleConnection myConn = new System.Data.OracleClient.OracleConnection(
"Data Source=Oracle8i;Integrated Security=yes");
System.Data.Odbc.OdbcConnection
常用的一些连接字符串(C#代码):
OdbcConnection conn = new OdbcConnection(
"Driver={SQL Server};Server=MyServer;Trusted_Connection=yes;Database=Northwind;");
OdbcConnection conn = new OdbcConnection(
"Driver={Microsoft ODBC for Oracle};Server=ORACLE8i7;
Persist Security Info=False;Trusted_Connection=yes");
OdbcConnection conn = new OdbcConnection(
"Driver={Microsoft Access Driver (*.mdb)};DBQ=c:binnwind.mdb");
OdbcConnection conn = new OdbcConnection(
"Driver={Microsoft Excel Driver (*.xls)};DBQ=c:binbook1.xls");
OdbcConnection conn = new OdbcConnection(
"Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=c:bin");
OdbcConnection conn = new OdbcConnection("DSN=dsnname");
其他厂商提供的数据库连接:
DB2Connection myConn = new IBM.Data.DB2.DB2Connection(
"DATABASE = SAMPLE;UID=<username>; PWD=<password>;");
DB2Connection myConn = new IBM.Data.DB2.DB2Connection("DATABASE = SAMPLE");
BdpConnection myConn = new Borland.Data.Provider.BdpConnection("assembly=Borl
and.Data.Mssql,Version=1.1.0.0,Culture=neutral,PublicKeyToken=91d62ebb5b0d1b1b;ve
ndorclient=sqloledb.dll;osauthentication=False;database=<database>;usernam
e=<user>;hostname=<host>;password=<password>;provider=MSSQL");
BdpConnection myConn = new Borland.Data.Provider.BdpConnection("assembly=Borl
and.Data.Db2,Version=1.1.0.0,Culture=neutral,PublicKeyToken=91d62ebb5b0d1b1b;ve
ndorclient=db2cli.dll;database=<database>;username=<user>;
password=<password>;provider=DB2");
Connection Pooling
在SQL Server、OLE DB和.NET框架结构中的Data Provider中,都提供了隐式的连接池连接支持。你可以在ConnectionString中指定不同的参数值控制连接池的行为。比如下面的例子使OLE DB的连接池无效并自动地进行事务处理:
Provider=SQLOLEDB;OLE DB Services=-4;Data Source=localhost;Integrated Security=SSPI;
在SQL Server.NET Data Provider中提供了以下参数设置控制连接池的行为:Connection Lifttime、Connection Reset、Enlist、Max Pool Size、Min Pool Size和Pooling。
更多数据库连接信息,以及非ADO.net的连接字符串可以参看:
http://www.connectionstrings.com/
ASP.NET获取客户端IP/用户名等信息
1. 在ASP.NET中专用属性:
获取服务器电脑名:Page.Server.ManchineName
获取用户信息:Page.User
获取客户端电脑名:Page.Request.UserHostName
获取客户端电脑IP:Page.Request.UserHostAddress
2. 在网络编程中的通用方法:
获取当前电脑名:static System.Net.Dns.GetHostName()
根据电脑名取出全部IP地址:static System.Net.Dns.Resolve(电脑名).AddressList
也可根据IP地址取出电脑名:static System.Net.Dns.Resolve(IP地址).HostName
3. 系统环境类的通用属性:
当前电脑名:static System.Environment.MachineName
当前电脑所属网域:static System.Environment.UserDomainName
当前电脑用户:static System.Environment.UserName
获取客户端IP:
private string GetClientIP()
{
string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (null == result || result == String.Empty)
{
result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
if (null == result || result == String.Empty)
{
result = HttpContext.Current.Request.UserHostAddress;
}
return result;
}
获取MAC地址:
using System.Runtime.InteropServices;
[DllImport("Iphlpapi.dll")]
private static extern int SendARP(Int32 dest,Int32 host,ref Int64 mac,ref Int32 length);
[DllImport("Ws2_32.dll")]
private static extern Int32 inet_addr(string ip);
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
try
{
string userip=Request.UserHostAddress;
string strClientIP = Request.UserHostAddress.ToString().Trim();
Int32 ldest = inet_addr(strClientIP); //目的地的ip
Int32 lhost = inet_addr(""); //本地服务器的ip
Int64 macinfo = new Int64();
Int32 len = 6;
int res = SendARP(ldest,0, ref macinfo, ref len);
string mac_src=macinfo.ToString("X");
if(mac_src == "0")
{
if(userip=="127.0.0.1")
Response.Write ("正在访问Localhost!");
else
Response.Write ("欢迎来自IP为" + userip + "的朋友!" + "<br>");
return;
}
while(mac_src.Length<12)
{
mac_src = mac_src.Insert(0,"0");
}
string mac_dest="";
for(int i=0;i<11;i++)
{
if (0 == (i % 2))
{
if ( i == 10 )
{
mac_dest = mac_dest.Insert(0,mac_src.Substring(i,2));
}
else
{
mac_dest ="-" + mac_dest.Insert(0,mac_src.Substring(i,2));
}
}
}
Response.Write ("欢迎来自IP为"+userip+ "<br>" + ",MAC地址为"+mac_dest+"的朋友!"
+ "<br>");
}
catch(Exception err)
{
Response.Write(err.Message);
}
}
IP=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If IP = "" Then IP=Request.ServerVariables("REMOTE_ADDR")
info=request.servervariables("http_user_agent")
response.cookies("buyok_user_ip")=ip
请教各位高手以上ASP代码是什么意思啊?
如果客户端使用了代理服务器,使用Request.ServerVariables("HTTP_X_FORWARDED_FOR") 得到IP地址,如果没用使用代理服务器,得到的是"",则用Request.ServerVariables("REMOTE_ADDR") 得到IP地址.
request.servervariables("http_user_agent") 得到用户HTTP设备的变量,如:你使用的IE浏览器版本,还有你的机器名和操作系统......
response.cookies("buyok_user_ip")=ip 是将得到的IP用Cookies对象写入客户端(变量名取为"buyok_user_ip")
《HTTP_X_FORWARDED_FOR & REMOTE_ADDR》
在 ASP 中使用 Request.ServerVariables("REMOTE_ADDR") 来取得客户端的 IP 地址,但如果客户端是使用代理服务器来访问,那取到的就是代理服务器的 IP 地址,而不是真正的客户端 IP 地址。要想透过代理服务器取得客户端的真实 IP 地址,就要使用 Request.ServerVariables("HTTP_X_FORWARDED_FOR") 来读取。
不过要注意的事,并不是每个代理服务器都能用 Request.ServerVariables("HTTP_X_FORWARDED_FOR") 来读取客户端的真实 IP,有些用此方法读取到的仍然是代理服务器的 IP。
还有一点需要注意的是:如果客户端没有通过代理服务器来访问,那么用Request.ServerVariables ("HTTP_X_FORWARDED_FOR") 取到的值将是空的。因此,如果要在程序中使用此方法,可以这样处理:
......
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR")
......
即:如果客户端通过代理服务器,则取 HTTP_X_FORWARDED_FOR 的值,如果没通过代理服务器,就取 REMOTE_ADDR 的值。
请牢记您BLOG的域名
http://flyingstarwb.itpub.net/
您BLOG的控制面板在
http://flyingstarwb.itpub.net/admin.php
登陆口令就是论坛口令,BLOG的口令和论坛是捆绑的。您可以在控制面板里完成发表文章,修改名称,模版以及观察统计数据等功能
全体ITPUB BLOG的内容首页在
http://weblog.itpub.net/
可以在这里了解整个ITPUB BLOG的状况,包括最新文章,BLOG列表,排名,统计数据等
怎样才可以使自己的BLOG变得知名?
只有宣传才可以使网站的访问增多,您可以把您的BLOG连接写在签名档里,或者在帖子里介绍给别的会员,也可以在别的网站和现实场合进行广泛的宣传。如果您的BLOG能被搜索引擎收录,那也对增加流量有所帮助。这也许需要您到一些常用搜索引擎那里登录一下。百度的登录入口:
http://www.baidu.com/search/url_submit.html
google的登录入口
http://www.google.com/intl/zh-CN/add_url.html
登录可以帮助您的BLOG尽快被收录(否则可能要等待比较长的时间)
法律责任
ITPUB是中华人民共和国境内网站,请大家在发表言论时注意遵守中华人民共和国法律,尊重知识产权,ITPUB只提供寄存平台,任何网友的个人言论都不代表ITPUB的观点,ITPUB也不会为网友的个人行为承担法律义务和责任。