终于在网上找到了解决方案:

在母版页的<head></head>中添加一个

<asp:contentplaceholder id="header" runat="server">
        
</asp:contentplaceholder>

 

然后在内容页中添加一个Content,如下:

<asp:Content ID="Content1" ContentPlaceHolderID="header" Runat="Server">
<link href="css.css" type="text/css" />
<script language="javascript" type="text/javascript">
alert(
"哈哈");
</script>
</asp:Content>

 

Ok,搞定!

posted @ 2008-12-11 19:00 唐德兵 阅读(144) | 评论 (1)编辑
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=|DataDirectory|Data.mdb");
        OleDbCommand cmd 
= new OleDbCommand("update student set xm=@xm where xh=@xh", con);

        cmd.Parameters.AddWithValue(
"@xh"this.TextBox1.Text);
        cmd.Parameters.AddWithValue(
"@xm"this.TextBox2.Text);

        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();

上面的代码很简单,只是更新一个字段,但是总是更新不成功!!后来终于在网上找到了解决方法。

OLE形式的SQL参数赋什的顺序必须与SQL语句参数顺序一样

交换一下参数就的顺序就OK了:

cmd.Parameters.AddWithValue("@xm"this.TextBox2.Text);
cmd.Parameters.AddWithValue(
"@xh"this.TextBox1.Text);
posted @ 2008-12-11 18:37 唐德兵 阅读(93) | 评论 (0)编辑
DateTime.Now.ToString("yyyyMMddHHmmssffff")
posted @ 2008-12-04 19:36 唐德兵 阅读(90) | 评论 (0)编辑
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(string password, string passwordFormat);
posted @ 2008-11-15 20:10 唐德兵 阅读(19) | 评论 (0)编辑
            //创建一个矩形对象
            Rectangle rect = new Rectangle();
            //通过一个函数对这个矩形对象赋值,这些值就是屏幕的工作区域
            rect = Screen.GetBounds(this);
            MessageBox.Show("本机器的分辨率是" + rect.Width.ToString() + "*" + rect.Height.ToString());
posted @ 2008-11-06 20:19 唐德兵 阅读(43) | 评论 (0)编辑
调用API
   
using System.Runtime.InteropServices;

    [DllImport(
"user32.dll")]
     
public static extern bool ReleaseCapture();
    [DllImport(
"user32.dll")]
    
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
   
public const int WM_SYSCOMMAND = 0x0112;
   
public const int SC_MOVE = 0xF010;
    
public const int HTCAPTION = 0x0002

//在空间的_MouseDown中加入如下代码:


    
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
   {
    ReleaseCapture();
    SendMessage(
this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
   }
posted @ 2008-11-06 18:59 唐德兵 阅读(59) | 评论 (0)编辑

 

插入:picPath是图片的路径

 try
            {
                
//把照片通过流的方式读取到字节数组中!
                FileStream fs = File.OpenRead(picPath);
                
byte[] b = new byte[fs.Length];
                fs.Read(b, 
0, b.Length);

                OleDbConnection con 
= new OleDbConnection(DB.connectionString);
                OleDbCommand cmd 
= new OleDbCommand("INSERT INTO Test (title,pic) VALUES (@title,@pic)", con);
                cmd.Parameters.Add(
"@title", OleDbType.VarChar).Value = txtTitle.Text;
                cmd.Parameters.Add(
"@pic", OleDbType.Binary).Value = b;

                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();

                MessageBox.Show(
"保存成功!");
            }
            
catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

 

读取:

 try
            {
                
string sql = "select pic from Test where Id = @Id";
                OleDbConnection con 
= new OleDbConnection(DB.connectionString);
                OleDbCommand cmd 
= new OleDbCommand(sql, con);
                cmd.Parameters.AddWithValue(
"@Id", txtId.Text);

                con.Open();
                
byte[] b = (byte[])cmd.ExecuteScalar();
                con.Close();

                
if (b != null)
                {
                    MemoryStream ms 
= new MemoryStream(b);
                    pictureBox1.Image 
= Image.FromStream(ms);
                }
                
else
                {
                    MessageBox.Show(
"未找到内容!");
                }
            }
            
catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
posted @ 2008-11-02 22:48 唐德兵 阅读(35) | 评论 (0)编辑
 /// <summary>
    
/// 替换html中的特殊字符
    
/// </summary>
    
/// <param name="text">需要进行替换的文本。</param>
    
/// <returns>替换完的文本。</returns>
    public string HtmlEncode(string text)
    {
        text 
= text.Replace(">""&gt;");
        text 
= text.Replace("<""&lt;");
        text 
= text.Replace(" ""&nbsp;");
        text 
= text.Replace(" ""&nbsp;");
        text 
= text.Replace("\"""&quot;");
        text = text.Replace("\'""'");
        text 
= text.Replace("\n""<br/> ");
        
return text;
    }

    
/// <summary>
    
/// 恢复html中的特殊字符
    
/// </summary>
    
/// <param name="text">需要恢复的文本。</param>
    
/// <returns>恢复好的文本。</returns>
    public string HtmlDecode(string text)
    {
        text 
= text.Replace("&gt;"">");
        text 
= text.Replace("&lt;""<");
        text 
= text.Replace("&nbsp;"" ");
        text 
= text.Replace("&nbsp;"" ");
        text 
= text.Replace("&quot;""\"");
        text = text.Replace("'""\'");
        text 
= text.Replace("<br/> ""\n");
        
return text;
    }
posted @ 2008-11-01 17:27 唐德兵 阅读(57) | 评论 (0)编辑

//使用System.Diagnostics下面的类Stopwatch精确测量程序执行需要的时间
            Stopwatch sw = new Stopwatch();
            sw.Start();

            
string s = "";
            
for (int i = 0; i < 50000; i++)
            {
                s 
+= i.ToString();
            }
            sw.Stop();
            Console.WriteLine(
"一共花费了{0}秒!",sw.ElapsedMilliseconds / 1000);

 

posted @ 2008-11-01 17:04 唐德兵 阅读(25) | 评论 (0)编辑

 

事务就是负责把一系列操作看做一个独立的逻辑单元,这些操作要么同时成功,要么同时失败。下面是一个经典的例子:

create procedure TransferMoeny
(
    
@FromAccountNo varchar(50),-- 转出账号
    @ToAccountNo varchar(50),--转入账号
    @MoneyCount money--转账金额
)
as
--判断账号是否存在
if exists (select 1 from 帐户表 where 账号 = @FromAccountNo
begin
    
if exists (select 1 from 帐户表 where 账号 = @ToAccountNo
    
begin
        
--判断转出金额是否大于当前余额
        if (select 当前余额 from 帐户表 where 账号 = @FromAccountNo>= @MoneyCount
        
begin
            
--开始转账
            begin transaction
            
insert into [存取记录表] ([账号],[存取类型][存取金额]values(@FromAccountNo-1,@MoneyCount)
            
if @@error <> 0
            
begin
                
rollback transaction--发生错误则回滚事务,无条件退出l
                return
            
end
                       
insert into [存取记录表] ([账号],[存取类型][存取金额]values(@ToAccountNo1,@MoneyCount)
            
if @@error <> 0
            
begin
                
rollback tran
                
return
            
end
            
commit transaction --两条语句都完成,提交事务
        end
        
else    
            
raiserror ('转账金额不能大于该账号的余额',16,1)
    
end
    
else
    
raiserror ('转入账号不存在',16,1)

end
else
    
raiserror ('转出账号不存在',16,1)

posted @ 2008-09-14 22:19 唐德兵 阅读(44) | 评论 (0)编辑