我的存储过程是想输出yymmdd+自动生成的编号,还要把他输出是页面上, 不知道该怎么解决,高手帮忙一下!!!
解决方案 »
- 如何在线编辑aspx,html等网页文件,我想在后台里在线编辑网站的所有网页文件
- 关于保存上传路径的问题
- datagrid分页高级玩法遇见问题
- asp.net 能不能使用虚拟内存
- 请教:如何在一个已有的aspx+cs里添加自己的js呢?
- GridView的问题?是否是Bug?
- 读取excel的问题
- 请高手帮忙解释一下:为什么我控件的条目创建了两次?涉及到Desinger
- 超连的问题。帮我看看.....
- 如何把客户端script的信息传到服务器端?
- 在一个页面上,有一个输入框,有一个按钮,点击按钮就把文本框中信息发送到一个邮箱中,没有发送者,怎么发送邮件,而且不用任何组件发送
- 在.NET中,如何使用webServices返回一个dataset,求例子
as
declare @cc
set @cc=year(getdate())+month(getdate())+day(getdate())+怎么个自动生成
select @cc
public string Getresult()
{
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("aa", myConnection); myCommand.CommandType = CommandType.StoredProcedure;
myConnection.Open();
try
{
string result=(string)myCommand.ExecuteScalar();
myConnection.Close();
return result;
}
catch(SqlException ee)
{
string e=ee.Message;
myConnection.Close();
return "";
}
}
as
declare @cc
set @cc=year(getdate())+month(getdate())+day(getdate())+怎么个自动生成
select @cc没有指定类型
AS
declare @y varchar(10),
@m varchar(10),
@d varchar(10),
@e datetime,
@cont int
begin
set @e=getdate()
set @y=str(year(@e))
set @m=str(month(@e))
set @d=str(day(@e))
if len(ltrim(rtrim(@m)))<2
begin
set @m='0'+ltrim(rtrim(@m))
end
if len(ltrim(rtrim(@d)))<2
begin
set @d='0'+ltrim(rtrim(@d))
end
set @str=ltrim(rtrim(@y))+ltrim(rtrim(@m))+ltrim(rtrim(@d))
select Batch_id into tmptable1 from ProductBatchTab where left(Batch_id,8)=@str
set @cont=(select count(Batch_id) as coun1 from tmptable1)+1
if len(@cont)<2
begin
set @str=ltrim(rtrim(str(@str)))+'0'+ltrim(rtrim(str(@cont)))
end
else
set @str=ltrim(rtrim(str(@str)))+ltrim(rtrim(str(@cont)))
select @str
drop table tmptable1
end
我的存储过程是这样的
我不知道如何调用!
as
return select year(getdate())+month(getdate())+day(getdate())+rand()
+rand()是什么意思 只要前边的不行吗?
加上几句:
string str;
SqlParameter myParameter = new SqlParameter("@str", str);
myParameter.Direction = ParameterDirection.Output;
set @mydate=CONVERT(char(6) , getdate(), 12 )
select @mydate
----result-----
051103
----result-----
declare @mydate varchar(12)
set @mydate=CONVERT(char(6) , getdate(), 12 ) //@mydate = 051103
declare @prebianhao char(12)
select @prebianhao=bianhao from tablename where bianhao =上一条记录//取得上一条记录编号,假设为05110301
declare @bianhao varchar(8)
set @bianhao=substring(@prebianhao,5,len(@prebianhao ))//取得上一条记录编号的最后几位,@bianhao=01
set @bianhao = convert(int,@bianhao)+1 //@bianhao=01
select @mydate + convert(char(6),@bianhao)+//得到新的05110302--------实验SQL---------
declare @mydate varchar(12)
set @mydate=CONVERT(char(6) , getdate(), 12 )
select @mydate
declare @bianhao varchar(8)
set @bianhao=substring(@mydate,5,len(@mydate))
set @bianhao = convert(int,@bianhao)+1
select @bianhao
select @mydate+convert(varchar(6),@bianhao)
我的意思就是把年月日取过来 ,后面+一个自动生成的编号,那怎么把这个编号显示在前台